All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
@ 2016-09-07 18:59 Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
                   ` (19 more replies)
  0 siblings, 20 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.

This is version 3 of the series, see individual patches for changes. It can
be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3

The series is probably still gated by lack of an ACK from Lenovo for the
relicensing patch (included here as patch 1).

Boris Ostrovsky (19):
  acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
  acpi/hvmloader: Collect processor and NUMA info in hvmloader
  acpi/hvmloader: Set TIS header address in hvmloader
  acpi/hvmloader: Make providing IOAPIC in MADT optional
  acpi/hvmloader: Build WAET optionally
  acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops
  acpi/hvmloader: Translate all addresses when assigning addresses in
    ACPI tables
  acpi/hvmloader: Link ACPI object files directly
  acpi/hvmloader: Include file/paths adjustments
  acpi: Move ACPI code to tools/libacpi
  x86: Allow LAPIC-only emulation_flags for HVM guests
  libacpi: Build DSDT for PVH guests
  acpi: Makefile should better tolerate interrupts
  libxc/libxl: Allow multiple ACPI modules
  libxl/acpi: Add ACPI e820 entry
  libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
  ilibxl: Initialize domain build info before calling libxl__domain_make
  libxl/acpi: Build ACPI tables for HVMlite guests
  libxc/xc_dom_core: Copy ACPI tables to guest space

 .gitignore                                         |  20 +-
 MAINTAINERS                                        |   1 +
 tools/firmware/hvmloader/Makefile                  |  20 +-
 tools/firmware/hvmloader/acpi/Makefile             |  72 -----
 tools/firmware/hvmloader/acpi/ssdt_tpm.asl         |  30 --
 tools/firmware/hvmloader/config.h                  |   2 +
 tools/firmware/hvmloader/hvmloader.c               |   2 +-
 tools/firmware/hvmloader/ovmf.c                    |   2 +-
 tools/firmware/hvmloader/rombios.c                 |   2 +-
 tools/firmware/hvmloader/seabios.c                 |   5 +-
 tools/firmware/hvmloader/util.c                    |  51 +++-
 tools/firmware/rombios/32bit/Makefile              |   2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile      |   2 +-
 tools/firmware/rombios/32bit/util.h                |   2 +-
 tools/libacpi/Makefile                             |  79 ++++++
 tools/{firmware/hvmloader/acpi => libacpi}/README  |  16 +-
 .../{firmware/hvmloader/acpi => libacpi}/acpi2_0.h |  19 +-
 tools/{firmware/hvmloader/acpi => libacpi}/build.c | 302 +++++++++++----------
 .../{firmware/hvmloader/acpi => libacpi}/dsdt.asl  |  38 +--
 tools/libacpi/dsdt_acpi_info.asl                   |  26 ++
 .../{firmware/hvmloader/acpi => libacpi}/libacpi.h |  48 +++-
 .../{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c |  20 ++
 .../hvmloader/acpi => libacpi}/ssdt_pm.asl         |  11 +-
 .../hvmloader/acpi => libacpi}/ssdt_s3.asl         |  11 +-
 .../hvmloader/acpi => libacpi}/ssdt_s4.asl         |  11 +-
 tools/libacpi/ssdt_tpm.asl                         |  28 ++
 .../hvmloader/acpi => libacpi}/static_tables.c     |  18 +-
 tools/libxc/include/xc_dom.h                       |   5 +-
 tools/libxc/xc_dom_core.c                          |  93 +++++++
 tools/libxc/xc_dom_hvmloader.c                     |   3 +-
 tools/libxl/Makefile                               |  20 +-
 tools/libxl/libxl_arch.h                           |   9 +
 tools/libxl/libxl_create.c                         |  22 +-
 tools/libxl/libxl_dom.c                            |  53 ++--
 tools/libxl/libxl_x86.c                            |  45 ++-
 tools/libxl/libxl_x86_acpi.c                       | 218 +++++++++++++++
 tools/libxl/libxl_x86_acpi.h                       |  35 +++
 xen/arch/x86/domain.c                              |  26 +-
 38 files changed, 975 insertions(+), 394 deletions(-)
 delete mode 100644 tools/firmware/hvmloader/acpi/Makefile
 delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_tpm.asl
 create mode 100644 tools/libacpi/Makefile
 rename tools/{firmware/hvmloader/acpi => libacpi}/README (60%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (95%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (63%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl (93%)
 create mode 100644 tools/libacpi/dsdt_acpi_info.asl
 rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (59%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (95%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (97%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (62%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (62%)
 create mode 100644 tools/libacpi/ssdt_tpm.asl
 rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (90%)
 create mode 100644 tools/libxl/libxl_x86_acpi.c
 create mode 100644 tools/libxl/libxl_x86_acpi.h

-- 
1.8.3.1


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

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

* [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 19:48   ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader Boris Ostrovsky
                   ` (18 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: Lars Kurth, Kevin Tian, wei.liu2, Kouya Shimura, andrew.cooper3,
	ian.jackson, julien.grall, Simon Horman, jbeulich, zhaoshenglong,
	Stefan Berger, boris.ostrovsky, Keir Fraser, Daniel Kiper,
	roger.pau

ACPI builder is currently distributed under GPLv2 license.

We plan to make the builder available to components other
than the hvmloader (which is also GPLv2). Some of these
components (such as libxl) may be distributed under LGPL-2.1
so that they can be used by non-GPLv2 callers.  But this
will not be possible if we incorporate the ACPI builder in
those other components.

To avoid this problem we are relicensing sources in ACPI
bulder directory to the Lesser GNU Public License (LGPL)
version 2.1

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Daniel Kiper <dkiper@net-space.pl>
Acked-by: Stefan Berger <stefanb@us.ibm.com>
Acked-by: Kouya Shimura <kouya@jp.fujitsu.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Simon Horman <horms@verge.net.au>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
CC: Daniel Kiper <dkiper@net-space.pl>
CC: Stefan Berger <stefanb@us.ibm.com>
CC: Kouya Shimura <kouya@jp.fujitsu.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Keir Fraser <keir@xen.org>
CC: Simon Horman <horms@verge.net.au>
CC: Lars Kurth <lars.kurth@citrix.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---

* Stll missing Lenovo ACK for commit 801d469ad8b2b88f669326327df03d03200efbfb

 tools/firmware/hvmloader/acpi/Makefile        | 18 ++++++++----------
 tools/firmware/hvmloader/acpi/acpi2_0.h       | 19 ++++++++-----------
 tools/firmware/hvmloader/acpi/build.c         | 18 ++++++++----------
 tools/firmware/hvmloader/acpi/dsdt.asl        | 18 ++++++++----------
 tools/firmware/hvmloader/acpi/mk_dsdt.c       | 12 ++++++++++++
 tools/firmware/hvmloader/acpi/ssdt_pm.asl     | 11 ++++-------
 tools/firmware/hvmloader/acpi/ssdt_s3.asl     | 11 ++++-------
 tools/firmware/hvmloader/acpi/ssdt_s4.asl     | 11 ++++-------
 tools/firmware/hvmloader/acpi/ssdt_tpm.asl    | 18 ++++++++----------
 tools/firmware/hvmloader/acpi/static_tables.c | 18 ++++++++----------
 10 files changed, 72 insertions(+), 82 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/firmware/hvmloader/acpi/Makefile
index d3e882a..703d67b 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/firmware/hvmloader/acpi/Makefile
@@ -1,17 +1,15 @@
 #
 # Copyright (c) 2004, Intel Corporation.
 #
-# This program is free software; you can redistribute it and/or modify it
-# under the terms and conditions of the GNU General Public License,
-# version 2, as published by the Free Software Foundation.
+# 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 it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; If not, see <http://www.gnu.org/licenses/>.
+# 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
+# NU Lesser General Public License for more details.
 #
 
 XEN_ROOT = $(CURDIR)/../../../..
diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h b/tools/firmware/hvmloader/acpi/acpi2_0.h
index 87a558a..775eb7a 100644
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h
@@ -1,18 +1,15 @@
 /*
  * Copyright (c) 2004, Intel Corporation.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
  */
 #ifndef _ACPI_2_0_H_
 #define _ACPI_2_0_H_
diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index dccddff..de56f1f 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -2,17 +2,15 @@
  * Copyright (c) 2004, Intel Corporation.
  * Copyright (c) 2006, Keir Fraser, XenSource Inc.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License, version 
- * 2, as published by the Free Software Foundation.
+ * 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 it will be useful, but WITHOUT ANY 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
+ * 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 "acpi2_0.h"
diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl
index bd65823..895a8e5 100644
--- a/tools/firmware/hvmloader/acpi/dsdt.asl
+++ b/tools/firmware/hvmloader/acpi/dsdt.asl
@@ -3,17 +3,15 @@
  *
  * Copyright (c) 2004, Intel Corporation.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
+ * 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 it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
+ * 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.
  */
 
 DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c b/tools/firmware/hvmloader/acpi/mk_dsdt.c
index b2ade89..bc414bf 100644
--- a/tools/firmware/hvmloader/acpi/mk_dsdt.c
+++ b/tools/firmware/hvmloader/acpi/mk_dsdt.c
@@ -1,3 +1,15 @@
+/*
+ * 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 <stdio.h>
 #include <stdarg.h>
 #include <stdint.h>
diff --git a/tools/firmware/hvmloader/acpi/ssdt_pm.asl b/tools/firmware/hvmloader/acpi/ssdt_pm.asl
index 1a7d752..d81b1f2 100644
--- a/tools/firmware/hvmloader/acpi/ssdt_pm.asl
+++ b/tools/firmware/hvmloader/acpi/ssdt_pm.asl
@@ -5,17 +5,14 @@
  * Copyright (c) 2008  Citrix Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ * GNU Lesser General Public License for more details.
  */
 
 /*
diff --git a/tools/firmware/hvmloader/acpi/ssdt_s3.asl b/tools/firmware/hvmloader/acpi/ssdt_s3.asl
index f89ac02..c83bbbf 100644
--- a/tools/firmware/hvmloader/acpi/ssdt_s3.asl
+++ b/tools/firmware/hvmloader/acpi/ssdt_s3.asl
@@ -4,17 +4,14 @@
  * Copyright (c) 2011  Citrix Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ * GNU Lesser General Public License for more details.
  */
 
 DefinitionBlock ("SSDT_S3.aml", "SSDT", 2, "Xen", "HVM", 0)
diff --git a/tools/firmware/hvmloader/acpi/ssdt_s4.asl b/tools/firmware/hvmloader/acpi/ssdt_s4.asl
index d589e4b..325ac11 100644
--- a/tools/firmware/hvmloader/acpi/ssdt_s4.asl
+++ b/tools/firmware/hvmloader/acpi/ssdt_s4.asl
@@ -4,17 +4,14 @@
  * Copyright (c) 2011  Citrix Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ * GNU Lesser General Public License for more details.
  */
 
 DefinitionBlock ("SSDT_S4.aml", "SSDT", 2, "Xen", "HVM", 0)
diff --git a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl
index 2ae8ad4..a0fb1fd 100644
--- a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl
+++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl
@@ -3,17 +3,15 @@
  *
  * Copyright (c) 2006, IBM Corporation.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
+ * 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 it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
+ * 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.
  */
 
 /* SSDT for TPM TIS Interface for Xen with Qemu device model. */
diff --git a/tools/firmware/hvmloader/acpi/static_tables.c b/tools/firmware/hvmloader/acpi/static_tables.c
index f4d627b..617bf68 100644
--- a/tools/firmware/hvmloader/acpi/static_tables.c
+++ b/tools/firmware/hvmloader/acpi/static_tables.c
@@ -2,17 +2,15 @@
  * Copyright (c) 2004, Intel Corporation.
  * Copyright (c) 2006, Keir Fraser, XenSource Inc.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
+ * 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 it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; If not, see <http://www.gnu.org/licenses/>.
+ * 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 "acpi2_0.h"
-- 
1.8.3.1


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

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

* [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 13:41   ` Jan Beulich
  2016-09-07 18:59 ` [PATCH v3 03/19] acpi/hvmloader: Set TIS header address " Boris Ostrovsky
                   ` (17 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

No need for ACPI code to rely on hvm_info variable.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Constified acpi_numa's pointers
* Constified acpi_config call parameter where possible

 tools/firmware/hvmloader/acpi/build.c   | 51 +++++++++++++++++----------------
 tools/firmware/hvmloader/acpi/libacpi.h | 13 +++++++++
 tools/firmware/hvmloader/util.c         |  9 ++++++
 3 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index de56f1f..5f5c5f0 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -70,18 +70,20 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(const struct acpi_config *config,
+                                           struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
     struct acpi_20_madt_intsrcovr *intsrcovr;
     struct acpi_20_madt_ioapic    *io_apic;
     struct acpi_20_madt_lapic     *lapic;
+    struct hvm_info_table         *hvminfo = config->hvminfo;
     int i, sz;
 
     sz  = sizeof(struct acpi_20_madt);
     sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
     sz += sizeof(struct acpi_20_madt_ioapic);
-    sz += sizeof(struct acpi_20_madt_lapic) * hvm_info->nr_vcpus;
+    sz += sizeof(struct acpi_20_madt_lapic) * hvminfo->nr_vcpus;
 
     madt = mem_alloc(sz, 16);
     if (!madt) return NULL;
@@ -134,9 +136,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_info *info)
     io_apic->ioapic_addr = ioapic_base_address;
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
-    info->nr_cpus = hvm_info->nr_vcpus;
+    info->nr_cpus = hvminfo->nr_vcpus;
     info->madt_lapic0_addr = (uint32_t)lapic;
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    for ( i = 0; i < hvminfo->nr_vcpus; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
@@ -144,7 +146,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_info *info)
         /* Processor ID must match processor-object IDs in the DSDT. */
         lapic->acpi_processor_id = i;
         lapic->apic_id = LAPIC_ID(i);
-        lapic->flags = (test_bit(i, hvm_info->vcpu_online)
+        lapic->flags = (test_bit(i, hvminfo->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
         lapic++;
     }
@@ -195,7 +197,7 @@ static struct acpi_20_waet *construct_waet(void)
     return waet;
 }
 
-static struct acpi_20_srat *construct_srat(void)
+static struct acpi_20_srat *construct_srat(const struct acpi_config *config)
 {
     struct acpi_20_srat *srat;
     struct acpi_20_srat_processor *processor;
@@ -204,8 +206,8 @@ static struct acpi_20_srat *construct_srat(void)
     void *p;
     unsigned int i;
 
-    size = sizeof(*srat) + sizeof(*processor) * hvm_info->nr_vcpus +
-           sizeof(*memory) * nr_vmemranges;
+    size = sizeof(*srat) + sizeof(*processor) * config->hvminfo->nr_vcpus +
+           sizeof(*memory) * config->numa.nr_vmemranges;
 
     p = mem_alloc(size, 16);
     if ( !p )
@@ -222,25 +224,26 @@ static struct acpi_20_srat *construct_srat(void)
     srat->table_revision      = ACPI_SRAT_TABLE_REVISION;
 
     processor = (struct acpi_20_srat_processor *)(srat + 1);
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
     {
         processor->type     = ACPI_PROCESSOR_AFFINITY;
         processor->length   = sizeof(*processor);
-        processor->domain   = vcpu_to_vnode[i];
+        processor->domain   = config->numa.vcpu_to_vnode[i];
         processor->apic_id  = LAPIC_ID(i);
         processor->flags    = ACPI_LOCAL_APIC_AFFIN_ENABLED;
         processor++;
     }
 
     memory = (struct acpi_20_srat_memory *)processor;
-    for ( i = 0; i < nr_vmemranges; i++ )
+    for ( i = 0; i < config->numa.nr_vmemranges; i++ )
     {
         memory->type          = ACPI_MEMORY_AFFINITY;
         memory->length        = sizeof(*memory);
-        memory->domain        = vmemrange[i].nid;
+        memory->domain        = config->numa.vmemrange[i].nid;
         memory->flags         = ACPI_MEM_AFFIN_ENABLED;
-        memory->base_address  = vmemrange[i].start;
-        memory->mem_length    = vmemrange[i].end - vmemrange[i].start;
+        memory->base_address  = config->numa.vmemrange[i].start;
+        memory->mem_length    = config->numa.vmemrange[i].end -
+                                config->numa.vmemrange[i].start;
         memory++;
     }
 
@@ -252,12 +255,12 @@ static struct acpi_20_srat *construct_srat(void)
     return srat;
 }
 
-static struct acpi_20_slit *construct_slit(void)
+static struct acpi_20_slit *construct_slit(const struct acpi_config *config)
 {
     struct acpi_20_slit *slit;
     unsigned int i, num, size;
 
-    num = nr_vnodes * nr_vnodes;
+    num = config->numa.nr_vnodes * config->numa.nr_vnodes;
     size = sizeof(*slit) + num * sizeof(uint8_t);
 
     slit = mem_alloc(size, 16);
@@ -274,9 +277,9 @@ static struct acpi_20_slit *construct_slit(void)
     slit->header.creator_revision = ACPI_CREATOR_REVISION;
 
     for ( i = 0; i < num; i++ )
-        slit->entry[i] = vdistance[i];
+        slit->entry[i] = config->numa.vdistance[i];
 
-    slit->localities = nr_vnodes;
+    slit->localities = config->numa.nr_vnodes;
 
     slit->header.length = size;
     set_checksum(slit, offsetof(struct acpi_header, checksum), size);
@@ -335,9 +338,9 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     void *lasa;
 
     /* MADT. */
-    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
+    if ( (config->hvminfo->nr_vcpus > 1) || config->hvminfo->apic_mode )
     {
-        madt = construct_madt(info);
+        madt = construct_madt(config, info);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
@@ -419,10 +422,10 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* SRAT and SLIT */
-    if ( nr_vnodes > 0 )
+    if ( config->numa.nr_vnodes > 0 )
     {
-        struct acpi_20_srat *srat = construct_srat();
-        struct acpi_20_slit *slit = construct_slit();
+        struct acpi_20_srat *srat = construct_srat(config);
+        struct acpi_20_slit *slit = construct_slit(config);
 
         if ( srat )
             table_ptrs[nr_tables++] = (unsigned long)srat;
@@ -515,7 +518,7 @@ void acpi_build_tables(struct acpi_config *config)
      * The latter is required for Windows 2000, which experiences a BSOD of
      * KMODE_EXCEPTION_NOT_HANDLED if it sees more than 15 processor objects.
      */
-    if ( hvm_info->nr_vcpus <= 15 && config->dsdt_15cpu)
+    if ( config->hvminfo->nr_vcpus <= 15 && config->dsdt_15cpu)
     {
         dsdt = mem_alloc(config->dsdt_15cpu_len, 16);
         if (!dsdt) goto oom;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index 22fd5f6..78c3a1c 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -20,6 +20,8 @@
 #ifndef __LIBACPI_H__
 #define __LIBACPI_H__
 
+#include <xen/memory.h>
+
 #define ACPI_HAS_COM1        (1<<0)
 #define ACPI_HAS_COM2        (1<<1)
 #define ACPI_HAS_LPT1        (1<<2)
@@ -29,6 +31,14 @@
 #define ACPI_HAS_SSDT_S4     (1<<6)
 
 
+struct acpi_numa {
+    uint32_t nr_vmemranges;
+    uint32_t nr_vnodes;
+    const unsigned int *vcpu_to_vnode;
+    const unsigned int *vdistance;
+    const struct xen_vmemrange *vmemrange;
+};
+
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
     unsigned int dsdt_anycpu_len;
@@ -49,6 +59,9 @@ struct acpi_config {
         uint32_t length;
     } pt;
 
+    struct acpi_numa numa;
+    struct hvm_info_table *hvminfo;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index b2d3421..f37b16e 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "hypercall.h"
 #include "ctype.h"
+#include "vnuma.h"
 #include "acpi/acpi2_0.h"
 #include "acpi/libacpi.h"
 #include <stdint.h>
@@ -918,6 +919,14 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
+    config->numa.nr_vmemranges = nr_vmemranges;
+    config->numa.nr_vnodes = nr_vnodes;
+    config->numa.vcpu_to_vnode = vcpu_to_vnode;
+    config->numa.vdistance = vdistance;
+    config->numa.vmemrange = vmemrange;
+
+    config->hvminfo = hvm_info;
+
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-- 
1.8.3.1


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

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

* [PATCH v3 03/19] acpi/hvmloader: Set TIS header address in hvmloader
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 04/19] acpi/hvmloader: Make providing IOAPIC in MADT optional Boris Ostrovsky
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Users other than hvmloader may provide TIS address as virtual.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 tools/firmware/hvmloader/acpi/build.c   | 9 ++++-----
 tools/firmware/hvmloader/acpi/libacpi.h | 3 +++
 tools/firmware/hvmloader/config.h       | 2 ++
 tools/firmware/hvmloader/util.c         | 4 ++++
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 5f5c5f0..80386b9 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -334,7 +334,6 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     struct acpi_20_tcpa *tcpa;
     unsigned char *ssdt;
     static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
-    uint16_t *tis_hdr;
     void *lasa;
 
     /* MADT. */
@@ -387,10 +386,10 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* TPM TCPA and SSDT. */
-    tis_hdr = (uint16_t *)0xFED40F00;
-    if ( (tis_hdr[0] == tis_signature[0]) &&
-         (tis_hdr[1] == tis_signature[1]) &&
-         (tis_hdr[2] == tis_signature[2]) )
+    if ( (config->table_flags & ACPI_HAS_TCPA) &&
+         (config->tis_hdr[0] == tis_signature[0]) &&
+         (config->tis_hdr[1] == tis_signature[1]) &&
+         (config->tis_hdr[2] == tis_signature[2]) )
     {
         ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
         if (!ssdt) return -1;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index 78c3a1c..cc57a9c 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -29,6 +29,7 @@
 #define ACPI_HAS_SSDT_PM     (1<<4)
 #define ACPI_HAS_SSDT_S3     (1<<5)
 #define ACPI_HAS_SSDT_S4     (1<<6)
+#define ACPI_HAS_TCPA        (1<<7)
 
 
 struct acpi_numa {
@@ -62,6 +63,8 @@ struct acpi_config {
     struct acpi_numa numa;
     struct hvm_info_table *hvminfo;
 
+    const uint16_t *tis_hdr;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h
index a4429f4..6e00413 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -56,6 +56,8 @@ extern uint8_t ioapic_version;
 /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
 #define PCI_MEM_END         0xfc000000
 
+#define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
+
 extern unsigned long pci_mem_start, pci_mem_end;
 extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
 
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index f37b16e..8875675 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -919,6 +919,10 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
+    config->table_flags |= ACPI_HAS_TCPA;
+
+    config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
+
     config->numa.nr_vmemranges = nr_vmemranges;
     config->numa.nr_vnodes = nr_vnodes;
     config->numa.vcpu_to_vnode = vcpu_to_vnode;
-- 
1.8.3.1


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

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

* [PATCH v3 04/19] acpi/hvmloader: Make providing IOAPIC in MADT optional
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (2 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 03/19] acpi/hvmloader: Set TIS header address " Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 05/19] acpi/hvmloader: Build WAET optionally Boris Ostrovsky
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 tools/firmware/hvmloader/acpi/build.c   | 70 ++++++++++++++++++---------------
 tools/firmware/hvmloader/acpi/libacpi.h |  1 +
 tools/firmware/hvmloader/util.c         |  2 +-
 3 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 80386b9..7e7c11f 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -99,43 +99,49 @@ static struct acpi_20_madt *construct_madt(const struct acpi_config *config,
     madt->lapic_addr = LAPIC_BASE_ADDRESS;
     madt->flags      = ACPI_PCAT_COMPAT;
 
-    intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
-    for ( i = 0; i < 16; i++ )
-    {
-        memset(intsrcovr, 0, sizeof(*intsrcovr));
-        intsrcovr->type   = ACPI_INTERRUPT_SOURCE_OVERRIDE;
-        intsrcovr->length = sizeof(*intsrcovr);
-        intsrcovr->source = i;
-
-        if ( i == 0 )
-        {
-            /* ISA IRQ0 routed to IOAPIC GSI 2. */
-            intsrcovr->gsi    = 2;
-            intsrcovr->flags  = 0x0;
-        }
-        else if ( PCI_ISA_IRQ_MASK & (1U << i) )
-        {
-            /* PCI: active-low level-triggered. */
-            intsrcovr->gsi    = i;
-            intsrcovr->flags  = 0xf;
-        }
-        else
+    if ( config->table_flags & ACPI_HAS_IOAPIC )
+    {     
+        intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
+        for ( i = 0; i < 16; i++ )
         {
-            /* No need for a INT source override structure. */
-            continue;
+            memset(intsrcovr, 0, sizeof(*intsrcovr));
+            intsrcovr->type   = ACPI_INTERRUPT_SOURCE_OVERRIDE;
+            intsrcovr->length = sizeof(*intsrcovr);
+            intsrcovr->source = i;
+
+            if ( i == 0 )
+            {
+                /* ISA IRQ0 routed to IOAPIC GSI 2. */
+                intsrcovr->gsi    = 2;
+                intsrcovr->flags  = 0x0;
+            }
+            else if ( PCI_ISA_IRQ_MASK & (1U << i) )
+            {
+                /* PCI: active-low level-triggered. */
+                intsrcovr->gsi    = i;
+                intsrcovr->flags  = 0xf;
+            }
+            else
+            {
+                /* No need for a INT source override structure. */
+                continue;
+            }
+
+            intsrcovr++;
         }
 
-        intsrcovr++;
-    }
+        io_apic = (struct acpi_20_madt_ioapic *)intsrcovr;
+        memset(io_apic, 0, sizeof(*io_apic));
+        io_apic->type        = ACPI_IO_APIC;
+        io_apic->length      = sizeof(*io_apic);
+        io_apic->ioapic_id   = IOAPIC_ID;
+        io_apic->ioapic_addr = ioapic_base_address;
 
-    io_apic = (struct acpi_20_madt_ioapic *)intsrcovr;
-    memset(io_apic, 0, sizeof(*io_apic));
-    io_apic->type        = ACPI_IO_APIC;
-    io_apic->length      = sizeof(*io_apic);
-    io_apic->ioapic_id   = IOAPIC_ID;
-    io_apic->ioapic_addr = ioapic_base_address;
+        lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
+    }
+    else
+        lapic = (struct acpi_20_madt_lapic *)(madt + 1);
 
-    lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     info->nr_cpus = hvminfo->nr_vcpus;
     info->madt_lapic0_addr = (uint32_t)lapic;
     for ( i = 0; i < hvminfo->nr_vcpus; i++ )
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index cc57a9c..b089cc5 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -30,6 +30,7 @@
 #define ACPI_HAS_SSDT_S3     (1<<5)
 #define ACPI_HAS_SSDT_S4     (1<<6)
 #define ACPI_HAS_TCPA        (1<<7)
+#define ACPI_HAS_IOAPIC      (1<<8)
 
 
 struct acpi_numa {
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index 8875675..aa5fc20 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -919,7 +919,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
-    config->table_flags |= ACPI_HAS_TCPA;
+    config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC);
 
     config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
 
-- 
1.8.3.1


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

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

* [PATCH v3 05/19] acpi/hvmloader: Build WAET optionally
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (3 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 04/19] acpi/hvmloader: Make providing IOAPIC in MADT optional Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops Boris Ostrovsky
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
Changes in v3:
* Broke "if ( !waet ) return -1;" line

 tools/firmware/hvmloader/acpi/build.c   | 10 +++++++---
 tools/firmware/hvmloader/acpi/libacpi.h |  1 +
 tools/firmware/hvmloader/util.c         |  2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 7e7c11f..1ea146f 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -359,9 +359,13 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* WAET. */
-    waet = construct_waet();
-    if (!waet) return -1;
-    table_ptrs[nr_tables++] = (unsigned long)waet;
+    if ( config->table_flags & ACPI_HAS_WAET )
+    {
+        waet = construct_waet();
+        if ( !waet )
+            return -1;
+        table_ptrs[nr_tables++] = (unsigned long)waet;
+    }
 
     if ( config->table_flags & ACPI_HAS_SSDT_PM )
     {
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index b089cc5..7a18d05 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -31,6 +31,7 @@
 #define ACPI_HAS_SSDT_S4     (1<<6)
 #define ACPI_HAS_TCPA        (1<<7)
 #define ACPI_HAS_IOAPIC      (1<<8)
+#define ACPI_HAS_WAET        (1<<9)
 
 
 struct acpi_numa {
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index aa5fc20..b345576 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -919,7 +919,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
-    config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC);
+    config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC | ACPI_HAS_WAET);
 
     config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
 
-- 
1.8.3.1


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

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

* [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (4 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 05/19] acpi/hvmloader: Build WAET optionally Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 13:54   ` Jan Beulich
  2016-09-07 18:59 ` [PATCH v3 07/19] acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables Boris Ostrovsky
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Components that wish to use ACPI builder will need to provide their own
mem_alloc() and virt_to_phys() routines. Pointers to these routines will
be passed to the builder as memory ops.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Constified more function call parameters
* Added a free() nop hook in util.c

 tools/firmware/hvmloader/acpi/build.c   | 95 ++++++++++++++++++---------------
 tools/firmware/hvmloader/acpi/libacpi.h | 10 +++-
 tools/firmware/hvmloader/util.c         | 23 +++++++-
 3 files changed, 83 insertions(+), 45 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 1ea146f..9c4a0a0 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -70,7 +70,8 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(const struct acpi_config *config,
+static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
+                                           const struct acpi_config *config,
                                            struct acpi_info *info)
 {
     struct acpi_20_madt           *madt;
@@ -85,7 +86,7 @@ static struct acpi_20_madt *construct_madt(const struct acpi_config *config,
     sz += sizeof(struct acpi_20_madt_ioapic);
     sz += sizeof(struct acpi_20_madt_lapic) * hvminfo->nr_vcpus;
 
-    madt = mem_alloc(sz, 16);
+    madt = ctxt->mem_ops.alloc(ctxt, sz, 16);
     if (!madt) return NULL;
 
     memset(madt, 0, sizeof(*madt));
@@ -165,11 +166,12 @@ static struct acpi_20_madt *construct_madt(const struct acpi_config *config,
     return madt;
 }
 
-static struct acpi_20_hpet *construct_hpet(void)
+static struct acpi_20_hpet *construct_hpet(struct acpi_ctxt *ctxt,
+                                           const struct acpi_config *config)
 {
     struct acpi_20_hpet *hpet;
 
-    hpet = mem_alloc(sizeof(*hpet), 16);
+    hpet = ctxt->mem_ops.alloc(ctxt, sizeof(*hpet), 16);
     if (!hpet) return NULL;
 
     memset(hpet, 0, sizeof(*hpet));
@@ -188,11 +190,12 @@ static struct acpi_20_hpet *construct_hpet(void)
     return hpet;
 }
 
-static struct acpi_20_waet *construct_waet(void)
+static struct acpi_20_waet *construct_waet(struct acpi_ctxt *ctxt,
+                                           const struct acpi_config *config)
 {
     struct acpi_20_waet *waet;
 
-    waet = mem_alloc(sizeof(*waet), 16);
+    waet = ctxt->mem_ops.alloc(ctxt, sizeof(*waet), 16);
     if (!waet) return NULL;
 
     memcpy(waet, &Waet, sizeof(*waet));
@@ -203,7 +206,8 @@ static struct acpi_20_waet *construct_waet(void)
     return waet;
 }
 
-static struct acpi_20_srat *construct_srat(const struct acpi_config *config)
+static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt,
+                                           const struct acpi_config *config)
 {
     struct acpi_20_srat *srat;
     struct acpi_20_srat_processor *processor;
@@ -215,7 +219,7 @@ static struct acpi_20_srat *construct_srat(const struct acpi_config *config)
     size = sizeof(*srat) + sizeof(*processor) * config->hvminfo->nr_vcpus +
            sizeof(*memory) * config->numa.nr_vmemranges;
 
-    p = mem_alloc(size, 16);
+    p = ctxt->mem_ops.alloc(ctxt, size, 16);
     if ( !p )
         return NULL;
 
@@ -261,7 +265,8 @@ static struct acpi_20_srat *construct_srat(const struct acpi_config *config)
     return srat;
 }
 
-static struct acpi_20_slit *construct_slit(const struct acpi_config *config)
+static struct acpi_20_slit *construct_slit(struct acpi_ctxt *ctxt,
+                                           const struct acpi_config *config)
 {
     struct acpi_20_slit *slit;
     unsigned int i, num, size;
@@ -269,7 +274,7 @@ static struct acpi_20_slit *construct_slit(const struct acpi_config *config)
     num = config->numa.nr_vnodes * config->numa.nr_vnodes;
     size = sizeof(*slit) + num * sizeof(uint8_t);
 
-    slit = mem_alloc(size, 16);
+    slit = ctxt->mem_ops.alloc(ctxt, size, 16);
     if ( !slit )
         return NULL;
 
@@ -293,7 +298,8 @@ static struct acpi_20_slit *construct_slit(const struct acpi_config *config)
     return slit;
 }
 
-static int construct_passthrough_tables(unsigned long *table_ptrs,
+static int construct_passthrough_tables(struct acpi_ctxt *ctxt,
+                                        unsigned long *table_ptrs,
                                         int nr_tables,
                                         struct acpi_config *config)
 {
@@ -316,7 +322,7 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
 
         header = (struct acpi_header*)pt_addr;
 
-        buffer = mem_alloc(header->length, 16);
+        buffer = ctxt->mem_ops.alloc(ctxt, header->length, 16);
         if ( buffer == NULL )
             break;
         memcpy(buffer, header, header->length);
@@ -329,7 +335,8 @@ static int construct_passthrough_tables(unsigned long *table_ptrs,
     return nr_added;
 }
 
-static int construct_secondary_tables(unsigned long *table_ptrs,
+static int construct_secondary_tables(struct acpi_ctxt *ctxt,
+                                      unsigned long *table_ptrs,
                                       struct acpi_config *config,
                                       struct acpi_info *info)
 {
@@ -345,7 +352,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* MADT. */
     if ( (config->hvminfo->nr_vcpus > 1) || config->hvminfo->apic_mode )
     {
-        madt = construct_madt(config, info);
+        madt = construct_madt(ctxt, config, info);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
@@ -353,7 +360,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* HPET. */
     if ( info->hpet_present )
     {
-        hpet = construct_hpet();
+        hpet = construct_hpet(ctxt, config);
         if (!hpet) return -1;
         table_ptrs[nr_tables++] = (unsigned long)hpet;
     }
@@ -361,7 +368,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* WAET. */
     if ( config->table_flags & ACPI_HAS_WAET )
     {
-        waet = construct_waet();
+        waet = construct_waet(ctxt, config);
         if ( !waet )
             return -1;
         table_ptrs[nr_tables++] = (unsigned long)waet;
@@ -369,7 +376,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
 
     if ( config->table_flags & ACPI_HAS_SSDT_PM )
     {
-        ssdt = mem_alloc(sizeof(ssdt_pm), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_pm, sizeof(ssdt_pm));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
@@ -377,7 +384,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
 
     if ( config->table_flags & ACPI_HAS_SSDT_S3 )
     {
-        ssdt = mem_alloc(sizeof(ssdt_s3), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s3, sizeof(ssdt_s3));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
@@ -387,7 +394,7 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
 
     if ( config->table_flags & ACPI_HAS_SSDT_S4 )
     {
-        ssdt = mem_alloc(sizeof(ssdt_s4), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s4, sizeof(ssdt_s4));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
@@ -401,12 +408,12 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
          (config->tis_hdr[1] == tis_signature[1]) &&
          (config->tis_hdr[2] == tis_signature[2]) )
     {
-        ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
+        ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm));
         table_ptrs[nr_tables++] = (unsigned long)ssdt;
 
-        tcpa = mem_alloc(sizeof(struct acpi_20_tcpa), 16);
+        tcpa = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_tcpa), 16);
         if (!tcpa) return -1;
         memset(tcpa, 0, sizeof(*tcpa));
         table_ptrs[nr_tables++] = (unsigned long)tcpa;
@@ -419,9 +426,9 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
         tcpa->header.oem_revision = ACPI_OEM_REVISION;
         tcpa->header.creator_id   = ACPI_CREATOR_ID;
         tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
-        if ( (lasa = mem_alloc(ACPI_2_0_TCPA_LAML_SIZE, 16)) != NULL )
+        if ( (lasa = ctxt->mem_ops.alloc(ctxt, ACPI_2_0_TCPA_LAML_SIZE, 16)) != NULL )
         {
-            tcpa->lasa = virt_to_phys(lasa);
+            tcpa->lasa = ctxt->mem_ops.v2p(ctxt, lasa);
             tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
             memset(lasa, 0, tcpa->laml);
             set_checksum(tcpa,
@@ -433,8 +440,8 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     /* SRAT and SLIT */
     if ( config->numa.nr_vnodes > 0 )
     {
-        struct acpi_20_srat *srat = construct_srat(config);
-        struct acpi_20_slit *slit = construct_slit(config);
+        struct acpi_20_srat *srat = construct_srat(ctxt, config);
+        struct acpi_20_slit *slit = construct_slit(ctxt, config);
 
         if ( srat )
             table_ptrs[nr_tables++] = (unsigned long)srat;
@@ -447,7 +454,8 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* Load any additional tables passed through. */
-    nr_tables += construct_passthrough_tables(table_ptrs, nr_tables, config);
+    nr_tables += construct_passthrough_tables(ctxt, table_ptrs,
+                                              nr_tables, config);
 
     table_ptrs[nr_tables] = 0;
     return nr_tables;
@@ -460,7 +468,8 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
  *
  * Return 0 if memory failure, != 0 if success
  */
-static int new_vm_gid(struct acpi_config *config,
+static int new_vm_gid(struct acpi_ctxt *ctxt,
+                      struct acpi_config *config,
                       struct acpi_info *info)
 {
     uint64_t *buf;
@@ -472,19 +481,19 @@ static int new_vm_gid(struct acpi_config *config,
         return 1;
 
     /* copy to allocate BIOS memory */
-    buf = mem_alloc(sizeof(config->vm_gid), 8);
+    buf = ctxt->mem_ops.alloc(ctxt, sizeof(config->vm_gid), 8);
     if ( !buf )
         return 0;
     memcpy(buf, config->vm_gid, sizeof(config->vm_gid));
 
     /* set the address into ACPI table and also pass it back to the caller */
-    info->vm_gid_addr = virt_to_phys(buf);
+    info->vm_gid_addr = ctxt->mem_ops.v2p(ctxt, buf);
     config->vm_gid_addr = info->vm_gid_addr;
 
     return 1;
 }
 
-void acpi_build_tables(struct acpi_config *config)
+void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -515,7 +524,7 @@ void acpi_build_tables(struct acpi_config *config)
      * Fill in high-memory data structures, starting at @buf.
      */
 
-    facs = mem_alloc(sizeof(struct acpi_20_facs), 16);
+    facs = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_facs), 16);
     if (!facs) goto oom;
     memcpy(facs, &Facs, sizeof(struct acpi_20_facs));
 
@@ -529,13 +538,13 @@ void acpi_build_tables(struct acpi_config *config)
      */
     if ( config->hvminfo->nr_vcpus <= 15 && config->dsdt_15cpu)
     {
-        dsdt = mem_alloc(config->dsdt_15cpu_len, 16);
+        dsdt = ctxt->mem_ops.alloc(ctxt, config->dsdt_15cpu_len, 16);
         if (!dsdt) goto oom;
         memcpy(dsdt, config->dsdt_15cpu, config->dsdt_15cpu_len);
     }
     else
     {
-        dsdt = mem_alloc(config->dsdt_anycpu_len, 16);
+        dsdt = ctxt->mem_ops.alloc(ctxt, config->dsdt_anycpu_len, 16);
         if (!dsdt) goto oom;
         memcpy(dsdt, config->dsdt_anycpu, config->dsdt_anycpu_len);
     }
@@ -548,7 +557,7 @@ void acpi_build_tables(struct acpi_config *config)
      * compatible revision 1 FADT that is linked with the RSDT. Refer to:
      *     http://www.acpi.info/presentations/S01USMOBS169_OS%20new.ppt
      */
-    fadt_10 = mem_alloc(sizeof(struct acpi_10_fadt), 16);
+    fadt_10 = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_10_fadt), 16);
     if (!fadt_10) goto oom;
     memcpy(fadt_10, &Fadt, sizeof(struct acpi_10_fadt));
     fadt_10->header.length = sizeof(struct acpi_10_fadt);
@@ -559,7 +568,7 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_10_fadt));
 
-    fadt = mem_alloc(sizeof(struct acpi_20_fadt), 16);
+    fadt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_fadt), 16);
     if (!fadt) goto oom;
     memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
     fadt->dsdt   = (unsigned long)dsdt;
@@ -570,14 +579,14 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    nr_secondaries = construct_secondary_tables(secondary_tables,
+    nr_secondaries = construct_secondary_tables(ctxt, secondary_tables,
                  config, acpi_info);
     if ( nr_secondaries < 0 )
         goto oom;
 
-    xsdt = mem_alloc(sizeof(struct acpi_20_xsdt)+
-                     sizeof(uint64_t)*nr_secondaries,
-                     16);
+    xsdt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_xsdt) + 
+                               sizeof(uint64_t) * nr_secondaries,
+                               16);
     if (!xsdt) goto oom;
     memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
     xsdt->entry[0] = (unsigned long)fadt;
@@ -588,9 +597,9 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_header, checksum),
                  xsdt->header.length);
 
-    rsdt = mem_alloc(sizeof(struct acpi_20_rsdt)+
-                     sizeof(uint32_t)*nr_secondaries,
-                     16);
+    rsdt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_rsdt) +
+                               sizeof(uint32_t) * nr_secondaries,
+                               16);
     if (!rsdt) goto oom;
     memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
     rsdt->entry[0] = (unsigned long)fadt_10;
@@ -616,7 +625,7 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    if ( !new_vm_gid(config, acpi_info) )
+    if ( !new_vm_gid(ctxt, config, acpi_info) )
         goto oom;
 
     return;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index 7a18d05..3bcd226 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -42,6 +42,14 @@ struct acpi_numa {
     const struct xen_vmemrange *vmemrange;
 };
 
+struct acpi_ctxt {
+    struct acpi_mem_ops {
+        void *(*alloc)(struct acpi_ctxt *ctxt, uint32_t size, uint32_t align);
+        void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
+        unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
+    } mem_ops;
+};
+
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
     unsigned int dsdt_anycpu_len;
@@ -78,7 +86,7 @@ struct acpi_config {
     unsigned int rsdp;
 };
 
-void acpi_build_tables(struct acpi_config *config);
+void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
 
 #endif /* __LIBACPI_H__ */
 
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index b345576..8773e69 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -866,10 +866,27 @@ static uint8_t battery_port_exists(void)
     return (inb(0x88) == 0x1F);
 }
 
+static unsigned long acpi_v2p(struct acpi_ctxt *ctxt, void *v)
+{
+    return virt_to_phys(v);
+}
+
+static void *acpi_mem_alloc(struct acpi_ctxt *ctxt,
+                            uint32_t size, uint32_t align)
+{
+    return mem_alloc(size, align);
+}
+
+static void acpi_mem_free(struct acpi_ctxt *ctxt,
+                          void *v, uint32_t size)
+{
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
     const char *s;
+    struct acpi_ctxt ctxt;
 
     /* Allocate and initialise the acpi info area. */
     mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
@@ -934,7 +951,11 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-    acpi_build_tables(config);
+    ctxt.mem_ops.alloc = acpi_mem_alloc;
+    ctxt.mem_ops.free = acpi_mem_free;
+    ctxt.mem_ops.v2p = acpi_v2p;
+
+    acpi_build_tables(&ctxt, config);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->vm_gid_addr);
 }
-- 
1.8.3.1


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

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

* [PATCH v3 07/19] acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (5 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly Boris Ostrovsky
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Non-hvmloader users may be building tables in virtual address space
and therefore we need to make sure that values that end up in tables
are physical addresses.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 tools/firmware/hvmloader/acpi/build.c | 47 ++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 9c4a0a0..2098920 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -144,7 +144,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
         lapic = (struct acpi_20_madt_lapic *)(madt + 1);
 
     info->nr_cpus = hvminfo->nr_vcpus;
-    info->madt_lapic0_addr = (uint32_t)lapic;
+    info->madt_lapic0_addr = ctxt->mem_ops.v2p(ctxt, lapic);
     for ( i = 0; i < hvminfo->nr_vcpus; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
@@ -161,7 +161,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
     madt->header.length = (unsigned char *)lapic - (unsigned char *)madt;
     set_checksum(madt, offsetof(struct acpi_header, checksum),
                  madt->header.length);
-    info->madt_csum_addr = (uint32_t)&madt->header.checksum;
+    info->madt_csum_addr =
+        ctxt->mem_ops.v2p(ctxt, &madt->header.checksum);
 
     return madt;
 }
@@ -327,7 +328,7 @@ static int construct_passthrough_tables(struct acpi_ctxt *ctxt,
             break;
         memcpy(buffer, header, header->length);
 
-        table_ptrs[nr_tables++] = (unsigned long)buffer;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, buffer);
         total += header->length;
         pt_addr += header->length;
     }
@@ -354,7 +355,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
     {
         madt = construct_madt(ctxt, config, info);
         if (!madt) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)madt;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, madt);
     }
 
     /* HPET. */
@@ -362,7 +363,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
     {
         hpet = construct_hpet(ctxt, config);
         if (!hpet) return -1;
-        table_ptrs[nr_tables++] = (unsigned long)hpet;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, hpet);
     }
 
     /* WAET. */
@@ -371,7 +372,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         waet = construct_waet(ctxt, config);
         if ( !waet )
             return -1;
-        table_ptrs[nr_tables++] = (unsigned long)waet;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, waet);
     }
 
     if ( config->table_flags & ACPI_HAS_SSDT_PM )
@@ -379,7 +380,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_pm), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_pm, sizeof(ssdt_pm));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt);
     }
 
     if ( config->table_flags & ACPI_HAS_SSDT_S3 )
@@ -387,7 +388,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s3), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s3, sizeof(ssdt_s3));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt);
     } else {
         printf("S3 disabled\n");
     }
@@ -397,7 +398,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s4), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_s4, sizeof(ssdt_s4));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt);
     } else {
         printf("S4 disabled\n");
     }
@@ -411,12 +412,12 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm), 16);
         if (!ssdt) return -1;
         memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm));
-        table_ptrs[nr_tables++] = (unsigned long)ssdt;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt);
 
         tcpa = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_tcpa), 16);
         if (!tcpa) return -1;
         memset(tcpa, 0, sizeof(*tcpa));
-        table_ptrs[nr_tables++] = (unsigned long)tcpa;
+        table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, tcpa);
 
         tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
         tcpa->header.length    = sizeof(*tcpa);
@@ -444,11 +445,11 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
         struct acpi_20_slit *slit = construct_slit(ctxt, config);
 
         if ( srat )
-            table_ptrs[nr_tables++] = (unsigned long)srat;
+            table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, srat);
         else
             printf("Failed to build SRAT, skipping...\n");
         if ( slit )
-            table_ptrs[nr_tables++] = (unsigned long)slit;
+            table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, slit);
         else
             printf("Failed to build SLIT, skipping...\n");
     }
@@ -562,8 +563,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     memcpy(fadt_10, &Fadt, sizeof(struct acpi_10_fadt));
     fadt_10->header.length = sizeof(struct acpi_10_fadt);
     fadt_10->header.revision = ACPI_1_0_FADT_REVISION;
-    fadt_10->dsdt          = (unsigned long)dsdt;
-    fadt_10->firmware_ctrl = (unsigned long)facs;
+    fadt_10->dsdt          = ctxt->mem_ops.v2p(ctxt, dsdt);
+    fadt_10->firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs);
     set_checksum(fadt_10,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_10_fadt));
@@ -571,10 +572,10 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     fadt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_fadt), 16);
     if (!fadt) goto oom;
     memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
-    fadt->dsdt   = (unsigned long)dsdt;
-    fadt->x_dsdt = (unsigned long)dsdt;
-    fadt->firmware_ctrl   = (unsigned long)facs;
-    fadt->x_firmware_ctrl = (unsigned long)facs;
+    fadt->dsdt   = ctxt->mem_ops.v2p(ctxt, dsdt);
+    fadt->x_dsdt = ctxt->mem_ops.v2p(ctxt, dsdt);
+    fadt->firmware_ctrl   = ctxt->mem_ops.v2p(ctxt, facs);
+    fadt->x_firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs);
     set_checksum(fadt,
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
@@ -589,7 +590,7 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
                                16);
     if (!xsdt) goto oom;
     memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
-    xsdt->entry[0] = (unsigned long)fadt;
+    xsdt->entry[0] = ctxt->mem_ops.v2p(ctxt, fadt);
     for ( i = 0; secondary_tables[i]; i++ )
         xsdt->entry[i+1] = secondary_tables[i];
     xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t);
@@ -602,7 +603,7 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
                                16);
     if (!rsdt) goto oom;
     memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
-    rsdt->entry[0] = (unsigned long)fadt_10;
+    rsdt->entry[0] = ctxt->mem_ops.v2p(ctxt, fadt_10);
     for ( i = 0; secondary_tables[i]; i++ )
         rsdt->entry[i+1] = secondary_tables[i];
     rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t);
@@ -616,8 +617,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     rsdp = (struct acpi_20_rsdp *)config->rsdp;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
-    rsdp->rsdt_address = (unsigned long)rsdt;
-    rsdp->xsdt_address = (unsigned long)xsdt;
+    rsdp->rsdt_address = ctxt->mem_ops.v2p(ctxt, rsdt);
+    rsdp->xsdt_address = ctxt->mem_ops.v2p(ctxt, xsdt);
     set_checksum(rsdp,
                  offsetof(struct acpi_10_rsdp, checksum),
                  sizeof(struct acpi_10_rsdp));
-- 
1.8.3.1


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

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

* [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (6 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 07/19] acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 13:56   ` Jan Beulich
  2016-09-07 18:59 ` [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments Boris Ostrovsky
                   ` (11 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

ACPI sources will be available to various component which will build
them according to their own rules. ACPI's Makefile will only generate
necessary source files.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Replace '(shell pwd) with CURDIR
* More use of addprefix

 .gitignore                             |  8 +++----
 tools/firmware/hvmloader/Makefile      | 11 ++++++++-
 tools/firmware/hvmloader/acpi/Makefile | 43 +++++++++++++++-------------------
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/.gitignore b/.gitignore
index 43c6f93..9b2c405 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt
 tools/firmware/etherboot/gpxe/*
 tools/firmware/extboot/extboot.img
 tools/firmware/extboot/signrom
-tools/firmware/hvmloader/acpi/mk_dsdt
-tools/firmware/hvmloader/acpi/dsdt*.c
-tools/firmware/hvmloader/acpi/dsdt_*.asl
-tools/firmware/hvmloader/acpi/ssdt_*.h
+tools/firmware/hvmloader/dsdt*.c
+tools/firmware/hvmloader/dsdt_*.asl
 tools/firmware/hvmloader/hvmloader
+tools/firmware/hvmloader/mk_dsdt
 tools/firmware/hvmloader/roms.h
 tools/firmware/hvmloader/roms.inc
+tools/firmware/hvmloader/ssdt_*.h
 tools/firmware/rombios/BIOS-bochs-[^/]*
 tools/firmware/rombios/_rombios[^/]*_.c
 tools/firmware/rombios/rombios[^/]*.s
diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 9f7357f..b6c5b83 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -20,6 +20,7 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
+export ACPI_BUILD_DIR=$(CURDIR)
 SUBDIRS := acpi
 
 # The HVM loader is started in 32-bit mode at the address below:
@@ -72,7 +73,15 @@ all: subdirs-all
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+ACPI_PATH = acpi
+ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
+$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
+vpath build.c $(ACPI_PATH)
+vpath static_tables.c $(ACPI_PATH)
+OBJS += $(ACPI_OBJS)
+
+hvmloader: $(OBJS)
 	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(LOADADDR) -o hvmloader.tmp $^
 	$(OBJCOPY) hvmloader.tmp hvmloader
 	rm -f hvmloader.tmp
diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/firmware/hvmloader/acpi/Makefile
index 703d67b..f635f18 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/firmware/hvmloader/acpi/Makefile
@@ -15,36 +15,37 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
-OBJS  = $(patsubst %.c,%.o,$(C_SRC))
+MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
-CFLAGS += $(CFLAGS_xeninclude)
+# Sources to be generated
+C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
+H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
-all: acpi.a
+all: $(C_SRC) $(H_SRC)
 
-ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
-	iasl -vs -p $* -tc $<
-	sed -e 's/AmlCode/$*/g' $*.hex >$@
-	rm -f $*.hex $*.aml
+$(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $<
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
+	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
 
-mk_dsdt: mk_dsdt.c
+$(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-dsdt_%cpu.asl: dsdt.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
+	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
-	iasl -vs -p $* -tc $*.asl
-	sed -e 's/AmlCode/$*/g' $*.hex >$@
+$(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/$*.asl
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
-	rm -f $*.aml $*.hex
+	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
 
 iasl:
 	@echo
@@ -54,14 +55,8 @@ iasl:
 	@echo 
 	@exit 1
 
-build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
-
-acpi.a: $(OBJS)
-	$(AR) rc $@ $(OBJS)
-
 clean:
-	rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
-	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
+	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC))
 
 distclean: clean
 
-- 
1.8.3.1


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

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

* [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (7 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 14:05   ` Jan Beulich
  2016-09-07 18:59 ` [PATCH v3 10/19] acpi: Move ACPI code to tools/libacpi Boris Ostrovsky
                   ` (10 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

In prepearation to moving acpi sources into generally available
libacpi:

1. Pass IOAPIC/LAPIC/PCI mask values via struct acpi_config
2. Modify include files search paths to point to acpi directory
3. Macro-ise include file for build.c that defines various
   utilities used by that file. Users of libacpi will be expected
   to define this macro when compiling build.c

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Instead of adding x86.h pass APIC/IOAPIC info via acpi_config parameter.
* Use <> instead of "" for include directive


 tools/firmware/hvmloader/Makefile             |  3 ++-
 tools/firmware/hvmloader/acpi/README          | 16 ++++++++++++----
 tools/firmware/hvmloader/acpi/build.c         | 19 ++++++++++---------
 tools/firmware/hvmloader/acpi/libacpi.h       |  7 +++++++
 tools/firmware/hvmloader/hvmloader.c          |  2 +-
 tools/firmware/hvmloader/rombios.c            |  2 +-
 tools/firmware/hvmloader/seabios.c            |  5 +++--
 tools/firmware/hvmloader/util.c               | 15 +++++++++++++--
 tools/firmware/rombios/32bit/Makefile         |  2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile |  2 +-
 tools/firmware/rombios/32bit/util.h           |  2 +-
 11 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index b6c5b83..77e95f1 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -76,7 +76,8 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 ACPI_PATH = acpi
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
+$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"../util.h\"
+CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
 OBJS += $(ACPI_OBJS)
diff --git a/tools/firmware/hvmloader/acpi/README b/tools/firmware/hvmloader/acpi/README
index 210d5ba..2b9d6e1 100644
--- a/tools/firmware/hvmloader/acpi/README
+++ b/tools/firmware/hvmloader/acpi/README
@@ -1,11 +1,19 @@
-ACPI Table for domain firmware
+ACPI builder for domain firmware
 
 
-INSTALL
+BUILDING ACPI
 -----------------
-Simply make is OK.
-# make 
+Users of ACPI builder are expected to provide an include file that makes available
+the following:
+* strncpy
+* printf
+* NULL
+* test_bit
+* offsetof
 
+When compiling build.c, the name of this include file should be given to
+compiler as -DLIBACPI_STDUTILS=\"<filename>\". See tools/firmware/hvmloader/Makefile
+for an example.
 
 Note on DSDT Table
 ------------------
diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 2098920..1cd640d 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -13,15 +13,13 @@
  * GNU Lesser General Public License for more details.
  */
 
+#include LIBACPI_STDUTILS
 #include "acpi2_0.h"
 #include "libacpi.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
-#include "../config.h"
-#include "../util.h"
-#include "../vnuma.h"
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
@@ -81,6 +79,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
     struct hvm_info_table         *hvminfo = config->hvminfo;
     int i, sz;
 
+    if ( config->lapic_id == NULL )
+        return NULL;
+
     sz  = sizeof(struct acpi_20_madt);
     sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
     sz += sizeof(struct acpi_20_madt_ioapic);
@@ -97,7 +98,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
     madt->header.oem_revision = ACPI_OEM_REVISION;
     madt->header.creator_id   = ACPI_CREATOR_ID;
     madt->header.creator_revision = ACPI_CREATOR_REVISION;
-    madt->lapic_addr = LAPIC_BASE_ADDRESS;
+    madt->lapic_addr = config->lapic_base_address;
     madt->flags      = ACPI_PCAT_COMPAT;
 
     if ( config->table_flags & ACPI_HAS_IOAPIC )
@@ -116,7 +117,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
                 intsrcovr->gsi    = 2;
                 intsrcovr->flags  = 0x0;
             }
-            else if ( PCI_ISA_IRQ_MASK & (1U << i) )
+            else if ( config->pci_isa_irq_mask & (1U << i) )
             {
                 /* PCI: active-low level-triggered. */
                 intsrcovr->gsi    = i;
@@ -135,8 +136,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
         memset(io_apic, 0, sizeof(*io_apic));
         io_apic->type        = ACPI_IO_APIC;
         io_apic->length      = sizeof(*io_apic);
-        io_apic->ioapic_id   = IOAPIC_ID;
-        io_apic->ioapic_addr = ioapic_base_address;
+        io_apic->ioapic_id   = config->ioapic_id;
+        io_apic->ioapic_addr = config->ioapic_base_address;
 
         lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     }
@@ -152,7 +153,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
         lapic->length  = sizeof(*lapic);
         /* Processor ID must match processor-object IDs in the DSDT. */
         lapic->acpi_processor_id = i;
-        lapic->apic_id = LAPIC_ID(i);
+        lapic->apic_id = config->lapic_id(i);
         lapic->flags = (test_bit(i, hvminfo->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
         lapic++;
@@ -240,7 +241,7 @@ static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt,
         processor->type     = ACPI_PROCESSOR_AFFINITY;
         processor->length   = sizeof(*processor);
         processor->domain   = config->numa.vcpu_to_vnode[i];
-        processor->apic_id  = LAPIC_ID(i);
+        processor->apic_id  = config->lapic_id(i);
         processor->flags    = ACPI_LOCAL_APIC_AFFIN_ENABLED;
         processor++;
     }
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index 3bcd226..d803139 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -84,6 +84,13 @@ struct acpi_config {
 
     /* RSDP address */
     unsigned int rsdp;
+
+    /* x86-specific parameters */
+    uint16_t (*lapic_id)(unsigned cpu);
+    uint32_t lapic_base_address;
+    uint32_t ioapic_base_address;
+    uint16_t pci_isa_irq_mask;
+    uint8_t ioapic_id;
 };
 
 void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
index bbd4e34..77b9536 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -24,8 +24,8 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
-#include "acpi/acpi2_0.h"
 #include "vnuma.h"
+#include <acpi2_0.h>
 #include <xen/version.h>
 #include <xen/hvm/params.h>
 #include <xen/arch-x86/hvm/start_info.h>
diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c
index 9acf03f..56b39b7 100644
--- a/tools/firmware/hvmloader/rombios.c
+++ b/tools/firmware/hvmloader/rombios.c
@@ -24,12 +24,12 @@
 #include "../rombios/config.h"
 
 #include "smbios_types.h"
-#include "acpi/libacpi.h"
 #include "pci_regs.h"
 #include "util.h"
 #include "hypercall.h"
 #include "option_rom.h"
 
+#include <libacpi.h>
 #include <xen/hvm/params.h>
 
 #define ROM_INCLUDE_ROMBIOS
diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
index 44ff0d7..870576a 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/tools/firmware/hvmloader/seabios.c
@@ -25,8 +25,9 @@
 #include "util.h"
 
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
-#include "acpi/libacpi.h"
+
+#include <acpi2_0.h>
+#include <libacpi.h>
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index 8773e69..6d636bf 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -22,8 +22,8 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "vnuma.h"
-#include "acpi/acpi2_0.h"
-#include "acpi/libacpi.h"
+#include <acpi2_0.h>
+#include <libacpi.h>
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
@@ -882,6 +882,11 @@ static void acpi_mem_free(struct acpi_ctxt *ctxt,
 {
 }
 
+static uint16_t acpi_lapic_id(unsigned cpu)
+{
+    return LAPIC_ID(cpu);
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
@@ -891,6 +896,12 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     /* Allocate and initialise the acpi info area. */
     mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
 
+    config->lapic_base_address = LAPIC_BASE_ADDRESS;
+    config->lapic_id = acpi_lapic_id;
+    config->ioapic_base_address = ioapic_base_address;
+    config->ioapic_id = IOAPIC_ID;
+    config->pci_isa_irq_mask = PCI_ISA_IRQ_MASK; 
+
     if ( uart_exists(0x3f8)  )
         config->table_flags |= ACPI_HAS_COM1;
     if (  uart_exists(0x2f8) )
diff --git a/tools/firmware/rombios/32bit/Makefile b/tools/firmware/rombios/32bit/Makefile
index 396906c..71399d2 100644
--- a/tools/firmware/rombios/32bit/Makefile
+++ b/tools/firmware/rombios/32bit/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi
 
 SUBDIRS = tcgbios
 
diff --git a/tools/firmware/rombios/32bit/tcgbios/Makefile b/tools/firmware/rombios/32bit/tcgbios/Makefile
index f6f2649..6822027 100644
--- a/tools/firmware/rombios/32bit/tcgbios/Makefile
+++ b/tools/firmware/rombios/32bit/tcgbios/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi
 
 .PHONY: all
 all: $(TARGET)
diff --git a/tools/firmware/rombios/32bit/util.h b/tools/firmware/rombios/32bit/util.h
index e245be6..6b90c43 100644
--- a/tools/firmware/rombios/32bit/util.h
+++ b/tools/firmware/rombios/32bit/util.h
@@ -1,7 +1,7 @@
 #ifndef UTIL_H
 #define UTIL_H
 
-#include "../hvmloader/acpi/acpi2_0.h"
+#include <acpi2_0.h>
 
 void outb(uint16_t addr, uint8_t val);
 void outw(uint16_t addr, uint16_t val);
-- 
1.8.3.1


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

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

* [PATCH v3 10/19] acpi: Move ACPI code to tools/libacpi
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (8 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 11/19] x86: Allow LAPIC-only emulation_flags for HVM guests Boris Ostrovsky
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 MAINTAINERS                                                |  1 +
 tools/firmware/hvmloader/Makefile                          | 14 ++++++++------
 tools/firmware/hvmloader/ovmf.c                            |  2 +-
 tools/firmware/rombios/32bit/Makefile                      |  2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile              |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/Makefile        |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/README          |  0
 tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/build.c         |  0
 tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl        |  0
 tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl    |  0
 tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c |  0
 17 files changed, 13 insertions(+), 10 deletions(-)
 rename tools/{firmware/hvmloader/acpi => libacpi}/Makefile (98%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/README (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 97720a8..07545f3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -138,6 +138,7 @@ S:	Supported
 F:	xen/arch/x86/acpi/
 F:	xen/drivers/acpi/
 F:	xen/include/acpi/
+F:	tools/libacpi/
 
 AMD IOMMU
 M:	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 77e95f1..9fa9bcc 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -20,9 +20,6 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-export ACPI_BUILD_DIR=$(CURDIR)
-SUBDIRS := acpi
-
 # The HVM loader is started in 32-bit mode at the address below:
 LOADADDR = 0x100000
 
@@ -67,16 +64,20 @@ ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
 endif
 
 .PHONY: all
-all: subdirs-all
+all: acpi subdirs-all
 	$(MAKE) hvmloader
 
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR)
+
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-ACPI_PATH = acpi
+ACPI_PATH = ../../libacpi
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"../util.h\"
+$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h\"
 CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
@@ -118,6 +119,7 @@ endif
 clean: subdirs-clean
 	rm -f roms.inc roms.inc.new acpi.h
 	rm -f hvmloader hvmloader.tmp *.o $(DEPS)
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) clean
 
 .PHONY: distclean
 distclean: clean
diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c
index 0ac3416..4ff7f1d 100644
--- a/tools/firmware/hvmloader/ovmf.c
+++ b/tools/firmware/hvmloader/ovmf.c
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "smbios_types.h"
-#include "acpi/libacpi.h"
+#include "libacpi.h"
 #include "apic_regs.h"
 #include "../rombios/config.h"
 #include "util.h"
diff --git a/tools/firmware/rombios/32bit/Makefile b/tools/firmware/rombios/32bit/Makefile
index 71399d2..b0583c9 100644
--- a/tools/firmware/rombios/32bit/Makefile
+++ b/tools/firmware/rombios/32bit/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi
 
 SUBDIRS = tcgbios
 
diff --git a/tools/firmware/rombios/32bit/tcgbios/Makefile b/tools/firmware/rombios/32bit/tcgbios/Makefile
index 6822027..f87d130 100644
--- a/tools/firmware/rombios/32bit/tcgbios/Makefile
+++ b/tools/firmware/rombios/32bit/tcgbios/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../../libacpi
 
 .PHONY: all
 all: $(TARGET)
diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/libacpi/Makefile
similarity index 98%
rename from tools/firmware/hvmloader/acpi/Makefile
rename to tools/libacpi/Makefile
index f635f18..6325cd0 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -12,7 +12,7 @@
 # NU Lesser General Public License for more details.
 #
 
-XEN_ROOT = $(CURDIR)/../../../..
+XEN_ROOT = $(CURDIR)/../../
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
diff --git a/tools/firmware/hvmloader/acpi/README b/tools/libacpi/README
similarity index 100%
rename from tools/firmware/hvmloader/acpi/README
rename to tools/libacpi/README
diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
similarity index 100%
rename from tools/firmware/hvmloader/acpi/acpi2_0.h
rename to tools/libacpi/acpi2_0.h
diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/libacpi/build.c
similarity index 100%
rename from tools/firmware/hvmloader/acpi/build.c
rename to tools/libacpi/build.c
diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/libacpi/dsdt.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/dsdt.asl
rename to tools/libacpi/dsdt.asl
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/libacpi/libacpi.h
similarity index 100%
rename from tools/firmware/hvmloader/acpi/libacpi.h
rename to tools/libacpi/libacpi.h
diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
similarity index 100%
rename from tools/firmware/hvmloader/acpi/mk_dsdt.c
rename to tools/libacpi/mk_dsdt.c
diff --git a/tools/firmware/hvmloader/acpi/ssdt_pm.asl b/tools/libacpi/ssdt_pm.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_pm.asl
rename to tools/libacpi/ssdt_pm.asl
diff --git a/tools/firmware/hvmloader/acpi/ssdt_s3.asl b/tools/libacpi/ssdt_s3.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s3.asl
rename to tools/libacpi/ssdt_s3.asl
diff --git a/tools/firmware/hvmloader/acpi/ssdt_s4.asl b/tools/libacpi/ssdt_s4.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s4.asl
rename to tools/libacpi/ssdt_s4.asl
diff --git a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl b/tools/libacpi/ssdt_tpm.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_tpm.asl
rename to tools/libacpi/ssdt_tpm.asl
diff --git a/tools/firmware/hvmloader/acpi/static_tables.c b/tools/libacpi/static_tables.c
similarity index 100%
rename from tools/firmware/hvmloader/acpi/static_tables.c
rename to tools/libacpi/static_tables.c
-- 
1.8.3.1


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

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

* [PATCH v3 11/19] x86: Allow LAPIC-only emulation_flags for HVM guests
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (9 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 10/19] acpi: Move ACPI code to tools/libacpi Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-07 18:59 ` [PATCH v3 12/19] libacpi: Build DSDT for PVH guests Boris Ostrovsky
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

PVHv2 guests may request LAPIC emulation (and nothing else)

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/domain.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 7ca1b66..135a7ae 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -545,25 +545,31 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
     }
     else
     {
-        if ( (config->emulation_flags & ~XEN_X86_EMU_ALL) != 0 )
+        uint32_t emflags;
+
+        if ( is_hardware_domain(d) )
+            config->emulation_flags |= XEN_X86_EMU_PIT;
+
+        emflags = config->emulation_flags;
+        if ( emflags & ~XEN_X86_EMU_ALL )
         {
             printk(XENLOG_G_ERR "d%d: Invalid emulation bitmap: %#x\n",
-                   d->domain_id, config->emulation_flags);
+                   d->domain_id, emflags);
             return -EINVAL;
         }
-        if ( is_hardware_domain(d) )
-            config->emulation_flags |= XEN_X86_EMU_PIT;
-        if ( config->emulation_flags != 0 &&
-             (config->emulation_flags !=
-              (is_hvm_domain(d) ? XEN_X86_EMU_ALL : XEN_X86_EMU_PIT)) )
+
+        /* PVHv2 guests can request emulated APIC. */
+        if ( emflags &&
+            (is_hvm_domain(d) ? ((emflags != XEN_X86_EMU_ALL) &&
+                                 (emflags != XEN_X86_EMU_LAPIC)) :
+                                (emflags != XEN_X86_EMU_PIT)) )
         {
             printk(XENLOG_G_ERR "d%d: Xen does not allow %s domain creation "
                    "with the current selection of emulators: %#x\n",
-                   d->domain_id, is_hvm_domain(d) ? "HVM" : "PV",
-                   config->emulation_flags);
+                   d->domain_id, is_hvm_domain(d) ? "HVM" : "PV", emflags);
             return -EOPNOTSUPP;
         }
-        d->arch.emulation_flags = config->emulation_flags;
+        d->arch.emulation_flags = emflags;
     }
 
     if ( has_hvm_container_domain(d) )
-- 
1.8.3.1


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

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

* [PATCH v3 12/19] libacpi: Build DSDT for PVH guests
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (10 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 11/19] x86: Allow LAPIC-only emulation_flags for HVM guests Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 14:09   ` Jan Beulich
  2016-09-14  4:13   ` Shannon Zhao
  2016-09-07 18:59 ` [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts Boris Ostrovsky
                   ` (7 subsequent siblings)
  19 siblings, 2 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

PVH guests require DSDT with only ACPI INFO (Xen-specific) and Processor
objects. We separate ASL's ACPI INFO definition into dsdt_acpi_info.asl so
that it can be included in ASLs for both HVM and PVH2.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Added comment to dsdt_acpi_info.asl indicating that the structure
  there must match struct acpi_info
* Use QEMU_NONE in mk_dsdt.c
* Makefile tweaks

 tools/libacpi/Makefile           | 13 ++++++++++---
 tools/libacpi/dsdt.asl           | 20 --------------------
 tools/libacpi/dsdt_acpi_info.asl | 26 ++++++++++++++++++++++++++
 tools/libacpi/mk_dsdt.c          |  8 ++++++++
 4 files changed, 44 insertions(+), 23 deletions(-)
 create mode 100644 tools/libacpi/dsdt_acpi_info.asl

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 6325cd0..12b081e 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -18,7 +18,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
 # Sources to be generated
-C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
+C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
@@ -32,15 +32,22 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
 $(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
+	cat dsdt_acpi_info.asl >> $@
 	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl $(MK_DSDT)
+$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
+	cat dsdt_acpi_info.asl >> $@
 	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
 
+$(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
+	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@
+	cat dsdt_acpi_info.asl >> $@
+	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@
+
 $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
 	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/$*.asl
 	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
diff --git a/tools/libacpi/dsdt.asl b/tools/libacpi/dsdt.asl
index 895a8e5..715bd7a 100644
--- a/tools/libacpi/dsdt.asl
+++ b/tools/libacpi/dsdt.asl
@@ -41,26 +41,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
 
     Scope (\_SB)
     {
-       /* ACPI_INFO_PHYSICAL_ADDRESS == 0xFC000000 */
-       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
-       Field(BIOS, ByteAcc, NoLock, Preserve) {
-           UAR1, 1,
-           UAR2, 1,
-           LTP1, 1,
-           HPET, 1,
-           Offset(2),
-           NCPU, 16,
-           PMIN, 32,
-           PLEN, 32,
-           MSUA, 32, /* MADT checksum address */
-           MAPA, 32, /* MADT LAPIC0 address */
-           VGIA, 32, /* VM generation id address */
-           LMIN, 32,
-           HMIN, 32,
-           LLEN, 32,
-           HLEN, 32
-       }
-
         /* Fix HCT test for 0x400 pci memory:
          * - need to report low 640 MB mem as motherboard resource
          */
diff --git a/tools/libacpi/dsdt_acpi_info.asl b/tools/libacpi/dsdt_acpi_info.asl
new file mode 100644
index 0000000..29e962a
--- /dev/null
+++ b/tools/libacpi/dsdt_acpi_info.asl
@@ -0,0 +1,26 @@
+
+    Scope (\_SB)
+    {
+       /*
+        * BIOS region must match struct acpi_info in build.c and
+	* be located at ACPI_INFO_PHYSICAL_ADDRESS = 0xFC000000
+	*/
+       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
+       Field(BIOS, ByteAcc, NoLock, Preserve) {
+           UAR1, 1,
+           UAR2, 1,
+           LTP1, 1,
+           HPET, 1,
+           Offset(2),
+           NCPU, 16,
+           PMIN, 32,
+           PLEN, 32,
+           MSUA, 32, /* MADT checksum address */
+           MAPA, 32, /* MADT LAPIC0 address */
+           VGIA, 32, /* VM generation id address */
+           LMIN, 32,
+           HMIN, 32,
+           LLEN, 32,
+           HLEN, 32
+       }
+    }
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index bc414bf..30477fd 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -23,6 +23,7 @@ static unsigned int indent_level;
 static bool debug = false;
 
 typedef enum dm_version {
+    QEMU_NONE,
     QEMU_XEN_TRADITIONAL,
     QEMU_XEN,
 } dm_version;
@@ -135,6 +136,8 @@ int main(int argc, char **argv)
                 dm_version = QEMU_XEN;
             } else if (strcmp(optarg, "qemu-xen-traditional") == 0) {
                 dm_version = QEMU_XEN_TRADITIONAL;
+            } else if (strcmp(optarg, "none") == 0) {
+                dm_version = QEMU_NONE;
             } else {
                 fprintf(stderr, "Unknown device model version `%s'.\n", optarg);
                 return -1;
@@ -252,6 +255,11 @@ int main(int argc, char **argv)
 
     pop_block();
 
+    if (dm_version == QEMU_NONE) {
+        pop_block();
+        return 0;
+    }
+
     /* Define GPE control method. */
     push_block("Scope", "\\_GPE");
     push_block("Method",
-- 
1.8.3.1


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

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

* [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (11 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 12/19] libacpi: Build DSDT for PVH guests Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 14:15   ` Jan Beulich
  2016-09-07 18:59 ` [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules Boris Ostrovsky
                   ` (6 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Intermediate stages of building a target should be made with
temporary files that are copied to final target in the end.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
New in v3

 tools/libacpi/Makefile | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 12b081e..2d8a954 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -21,38 +21,45 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
+ifeq ($(subst all,,$(MAKECMDGOALS)),)
+TDIR := $(shell mktemp -d --tmpdir=$(TMPDIR) tmp_XXXXXX)
+endif
+
 vpath iasl $(PATH)
 all: $(C_SRC) $(H_SRC)
+	rm -fr $(TDIR)
 
 $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
-	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $<
-	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
-	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
+	iasl -vs -p $(TDIR)/$* -tc $<
+	sed -e 's/AmlCode/$*/g' $(TDIR)/$*.hex > $@
 
 $(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
-	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	cat dsdt_acpi_info.asl >> $@
-	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
+	awk 'NR > 1 {print s} {s=$$0}' $< > $(TDIR)/$(@F)
+	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $(TDIR)/$(@F)
+	cp $(TDIR)/$(@F) $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
 $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
-	awk 'NR > 1 {print s} {s=$$0}' $< > $@
-	cat dsdt_acpi_info.asl >> $@
-	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
+	awk 'NR > 1 {print s} {s=$$0}' $< > $(TDIR)/$(@F)
+	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $(TDIR)/$(@F)
+	cp $(TDIR)/$(@F) $@
 
 $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
-	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@
-	cat dsdt_acpi_info.asl >> $@
-	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@
+	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $(TDIR)/$(@F)
+	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $(TDIR)/$(@F)
+	cp $(TDIR)/$(@F) $@
 
 $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
-	iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/$*.asl
-	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
-	echo "int $*_len=sizeof($*);" >>$@
-	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
+	iasl -vs -p $(TDIR)/$* -tc $(TDIR)/$*.asl
+	sed -e 's/AmlCode/$*/g' $(TDIR)/$*.hex > $(TDIR)/$(@F)
+	echo "int $*_len=sizeof($*);" >> $(TDIR)/$(@F)
+	cp $(TDIR)/$(@F) $@
 
 iasl:
 	@echo
-- 
1.8.3.1


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

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

* [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (12 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-15 10:13   ` Wei Liu
  2016-09-07 18:59 ` [PATCH v3 15/19] libxl/acpi: Add ACPI e820 entry Boris Ostrovsky
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Provide ability to load multiple ACPI modules. Thie feature is needed
by PVHv2 guests and will be used in subsequent patches.

We assume that PVHv2 guests do not load their ACPI modules specified
in the configuration file. We can extend support for that in the future
if desired.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Constified info parameter to hvm_build_set_xs_values()

 tools/libxc/include/xc_dom.h   |  5 +++--
 tools/libxc/xc_dom_hvmloader.c |  3 ++-
 tools/libxl/libxl_dom.c        | 26 ++++++++++++++++++--------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index de7dca9..608cbc2 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -212,8 +212,9 @@ struct xc_dom_image {
     /* BIOS/Firmware passed to HVMLOADER */
     struct xc_hvm_firmware_module system_firmware_module;
 
-    /* Extra ACPI tables passed to HVMLOADER */
-    struct xc_hvm_firmware_module acpi_module;
+    /* Extra ACPI tables */
+#define MAX_ACPI_MODULES        4
+    struct xc_hvm_firmware_module acpi_modules[MAX_ACPI_MODULES];
 
     /* Extra SMBIOS structures passed to HVMLOADER */
     struct xc_hvm_firmware_module smbios_module;
diff --git a/tools/libxc/xc_dom_hvmloader.c b/tools/libxc/xc_dom_hvmloader.c
index 6eb8516..59f94e5 100644
--- a/tools/libxc/xc_dom_hvmloader.c
+++ b/tools/libxc/xc_dom_hvmloader.c
@@ -172,7 +172,8 @@ static int modules_init(struct xc_dom_image *dom)
     rc = module_init_one(dom, &dom->system_firmware_module,
                          "System Firmware module");
     if ( rc ) goto err;
-    rc = module_init_one(dom, &dom->acpi_module, "ACPI module");
+    /* Only one module can be added */
+    rc = module_init_one(dom, &dom->acpi_modules[0], "ACPI module");
     if ( rc ) goto err;
     rc = module_init_one(dom, &dom->smbios_module, "SMBIOS module");
     if ( rc ) goto err;
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index c895649..c4be916 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -818,7 +818,8 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
 
 static int hvm_build_set_xs_values(libxl__gc *gc,
                                    uint32_t domid,
-                                   struct xc_dom_image *dom)
+                                   struct xc_dom_image *dom,
+                                   const libxl_domain_build_info *info)
 {
     char *path = NULL;
     int ret = 0;
@@ -839,18 +840,20 @@ static int hvm_build_set_xs_values(libxl__gc *gc,
             goto err;
     }
 
-    if (dom->acpi_module.guest_addr_out) {
+    /* Only one module can be passed. PVHv2 guests do not support this. */
+    if (dom->acpi_modules[0].guest_addr_out && 
+        info->device_model_version !=LIBXL_DEVICE_MODEL_VERSION_NONE) {
         path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_ADDRESS, domid);
 
         ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%"PRIx64,
-                               dom->acpi_module.guest_addr_out);
+                               dom->acpi_modules[0].guest_addr_out);
         if (ret)
             goto err;
 
         path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_LENGTH, domid);
 
         ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%x",
-                               dom->acpi_module.length);
+                               dom->acpi_modules[0].length);
         if (ret)
             goto err;
     }
@@ -994,6 +997,13 @@ static int libxl__domain_firmware(libxl__gc *gc,
     }
 
     if (info->u.hvm.acpi_firmware) {
+
+        if (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE) {
+            LOGE(ERROR, "PVH guests do not allow loading ACPI modules");
+            rc = ERROR_FAIL;
+            goto out;
+        }
+
         data = NULL;
         e = libxl_read_file_contents(ctx, info->u.hvm.acpi_firmware,
                                      &data, &datalen);
@@ -1005,9 +1015,9 @@ static int libxl__domain_firmware(libxl__gc *gc,
         }
         libxl__ptr_add(gc, data);
         if (datalen) {
-            /* Only accept non-empty files */
-            dom->acpi_module.data = data;
-            dom->acpi_module.length = (uint32_t)datalen;
+            /* Only accept a non-empty file */
+            dom->acpi_modules[0].data = data;
+            dom->acpi_modules[0].length = (uint32_t)datalen;
         }
     }
 
@@ -1143,7 +1153,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
-    rc = hvm_build_set_xs_values(gc, domid, dom);
+    rc = hvm_build_set_xs_values(gc, domid, dom, info);
     if (rc != 0) {
         LOG(ERROR, "hvm build set xenstore values failed");
         goto out;
-- 
1.8.3.1


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

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

* [PATCH v3 15/19] libxl/acpi: Add ACPI e820 entry
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (13 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-15 10:13   ` Wei Liu
  2016-09-07 18:59 ` [PATCH v3 16/19] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests Boris Ostrovsky
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Add entry for ACPI tables created for PVHv2 guests to e820 map.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* format adjustments

 tools/libxl/libxl_dom.c |  8 ++++----
 tools/libxl/libxl_x86.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index c4be916..7974302 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -1134,16 +1134,16 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
             dom->vnode_to_pnode[i] = info->vnuma_nodes[i].pnode;
     }
 
+    rc = libxl__build_dom(gc, domid, info, state, dom);
+    if (rc != 0)
+        goto out;
+
     rc = libxl__arch_domain_construct_memmap(gc, d_config, domid, dom);
     if (rc != 0) {
         LOG(ERROR, "setting domain memory map failed");
         goto out;
     }
 
-    rc = libxl__build_dom(gc, domid, info, state, dom);
-    if (rc != 0)
-        goto out;
-
     rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
                                &state->console_mfn, state->store_domid,
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 46cfafb..2b221aa 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -492,6 +492,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     uint64_t highmem_size =
                     dom->highmem_end ? dom->highmem_end - (1ull << 32) : 0;
     uint32_t lowmem_start = dom->device_model ? GUEST_LOW_MEM_START_DEFAULT : 0;
+    unsigned page_size = XC_DOM_PAGE_SIZE(dom);
 
     /* Add all rdm entries. */
     for (i = 0; i < d_config->num_rdms; i++)
@@ -503,6 +504,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     if (highmem_size)
         e820_entries++;
 
+    for (i = 0; i < MAX_ACPI_MODULES; i++)
+        if (dom->acpi_modules[i].length)
+            e820_entries++;
+
     if (e820_entries >= E820MAX) {
         LOG(ERROR, "Ooops! Too many entries in the memory map!");
         rc = ERROR_INVAL;
@@ -528,6 +533,16 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
         nr++;
     }
 
+    for (i = 0; i < MAX_ACPI_MODULES; i++) {
+        if (dom->acpi_modules[i].length) {
+            e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size - 1);
+            e820[nr].size = dom->acpi_modules[i].length +
+                (dom->acpi_modules[i].guest_addr_out & (page_size - 1));
+            e820[nr].type = E820_ACPI;
+            nr++;
+        }
+    }
+
     /* High memory */
     if (highmem_size) {
         e820[nr].addr = ((uint64_t)1 << 32);
-- 
1.8.3.1


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

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

* [PATCH v3 16/19] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (14 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 15/19] libxl/acpi: Add ACPI e820 entry Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-15 10:13   ` Wei Liu
  2016-09-07 18:59 ` [PATCH v3 17/19] ilibxl: Initialize domain build info before calling libxl__domain_make Boris Ostrovsky
                   ` (3 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Now that we don't have x86.h define LAPIC_BASE_ADDRESS in libxl_arch.h

 tools/libxl/Makefile     |  2 ++
 tools/libxl/libxl_arch.h |  6 ++++++
 tools/libxl/libxl_dom.c  | 19 +++++++++++++++----
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 14a1a8e..1f3b40f 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -166,6 +166,8 @@ $(XL_OBJS) $(TEST_PROG_OBJS) _libxl.api-for-check: \
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
 $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
 
+libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
+
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
 
diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index 34a853c..253a037 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -62,4 +62,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
                                         uint32_t domid,
                                         struct xc_dom_image *dom);
 
+#if defined(__i386__) || defined(__x86_64__)
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
+
+#endif
+
 #endif
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 7974302..2924629 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -1077,10 +1077,21 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         dom->target_pages = mem_size >> XC_PAGE_SHIFT;
     if (dom->mmio_size == 0 && device_model)
         dom->mmio_size = HVM_BELOW_4G_MMIO_LENGTH;
-    else if (dom->mmio_size == 0 && !device_model)
-        dom->mmio_size = GB(4) -
-                    ((X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES)
-                    << XC_PAGE_SHIFT);
+    else if (dom->mmio_size == 0 && !device_model) {
+#if defined(__i386__) || defined(__x86_64__)
+        if (libxl_defbool_val(info->u.hvm.apic)) {
+            /* Make sure LAPIC_BASE_ADDRESS is below special pages */
+            assert(((((X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES)
+                      << XC_PAGE_SHIFT) - LAPIC_BASE_ADDRESS)) >= XC_PAGE_SIZE);
+            dom->mmio_size = GB(4) - LAPIC_BASE_ADDRESS;
+        } else
+            dom->mmio_size = GB(4) -
+                ((X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES)
+                 << XC_PAGE_SHIFT);
+#else
+        assert(1);
+#endif
+    }
     lowmem_end = mem_size;
     highmem_end = 0;
     mmio_start = (1ull << 32) - dom->mmio_size;
-- 
1.8.3.1


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

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

* [PATCH v3 17/19] ilibxl: Initialize domain build info before calling libxl__domain_make
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (15 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 16/19] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-15 10:13   ` Wei Liu
  2016-09-07 18:59 ` [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests Boris Ostrovsky
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

libxl__domain_make() may want to use b_info so we should set defaults
a little earlier.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 tools/libxl/libxl_create.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 04f8ae9..07b2b4b 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -899,17 +899,6 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
-    ret = libxl__domain_make(gc, d_config, &domid, &state->config);
-    if (ret) {
-        LOG(ERROR, "cannot make domain: %d", ret);
-        dcs->guest_domid = domid;
-        ret = ERROR_FAIL;
-        goto error_out;
-    }
-
-    dcs->guest_domid = domid;
-    dcs->sdss.dm.guest_domid = 0; /* means we haven't spawned */
-
     ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info);
     if (ret) {
         LOG(ERROR, "Unable to set domain build info defaults");
@@ -923,6 +912,17 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
+    ret = libxl__domain_make(gc, d_config, &domid, &state->config);
+    if (ret) {
+        LOG(ERROR, "cannot make domain: %d", ret);
+        dcs->guest_domid = domid;
+        ret = ERROR_FAIL;
+        goto error_out;
+    }
+
+    dcs->guest_domid = domid;
+    dcs->sdss.dm.guest_domid = 0; /* means we haven't spawned */
+
     /*
      * Set the dm version quite early so that libxl doesn't have to pass the
      * build info around just to know if the domain has a device model or not.
-- 
1.8.3.1


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

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

* [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (16 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 17/19] ilibxl: Initialize domain build info before calling libxl__domain_make Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-08 14:20   ` Jan Beulich
  2016-09-07 18:59 ` [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space Boris Ostrovsky
  2016-09-14 15:21 ` [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Some constification of call parameters
* Format adjustments
* New acpi_mem_free hook (a nop)
* Changes in init_acpi_config() to deal with constified acpi_numa's
  pointers (initialize pointers as temp variabales)
* Add '-include acpi' directive in Makefile to make sure acpi
  target is built before build.o dependencies are processed
  (specifically, ssdt_*.h files need to exist)


 .gitignore                   |  12 ++-
 tools/libacpi/build.c        |   7 +-
 tools/libacpi/libacpi.h      |  15 ++-
 tools/libxl/Makefile         |  18 +++-
 tools/libxl/libxl_arch.h     |   3 +
 tools/libxl/libxl_x86.c      |  30 ++++--
 tools/libxl/libxl_x86_acpi.c | 218 +++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_x86_acpi.h |  35 +++++++
 8 files changed, 318 insertions(+), 20 deletions(-)
 create mode 100644 tools/libxl/libxl_x86_acpi.c
 create mode 100644 tools/libxl/libxl_x86_acpi.h

diff --git a/.gitignore b/.gitignore
index 9b2c405..9f5bd8c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -173,15 +173,19 @@ tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libxl/libxlu_cfg_y.output
+tools/libxl/_libxl.api-for-check
+tools/libxl/*.api-ok
 tools/libxl/*.pc
 tools/libxl/*.pc.in
-tools/libxl/xl
+tools/libxl/dsdt*.c
+tools/libxl/dsdt_*.asl
+tools/libxl/libxlu_cfg_y.output
+tools/libxl/mk_dsdt
+tools/libxl/ssdt_*.h
 tools/libxl/testenum
 tools/libxl/testenum.c
 tools/libxl/tmp.*
-tools/libxl/_libxl.api-for-check
-tools/libxl/*.api-ok
+tools/libxl/xl
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
index 1cd640d..ee5f779 100644
--- a/tools/libacpi/build.c
+++ b/tools/libacpi/build.c
@@ -20,6 +20,7 @@
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
+#include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
@@ -495,7 +496,7 @@ static int new_vm_gid(struct acpi_ctxt *ctxt,
     return 1;
 }
 
-void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
+int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
 {
     struct acpi_info *acpi_info;
     struct acpi_20_rsdp *rsdp;
@@ -630,11 +631,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     if ( !new_vm_gid(ctxt, config, acpi_info) )
         goto oom;
 
-    return;
+    return 0;
 
 oom:
     printf("unable to build ACPI tables: out of memory\n");
-
+    return -1;
 }
 
 /*
diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h
index d803139..b0ff5aa 100644
--- a/tools/libacpi/libacpi.h
+++ b/tools/libacpi/libacpi.h
@@ -48,6 +48,15 @@ struct acpi_ctxt {
         void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
         unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
     } mem_ops;
+
+    unsigned int page_size;
+    unsigned int page_shift;
+
+    /* Memory allocator */
+    unsigned long alloc_base_paddr;
+    unsigned long alloc_base_vaddr;
+    unsigned long alloc_currp;
+    unsigned long alloc_end;
 };
 
 struct acpi_config {
@@ -80,10 +89,10 @@ struct acpi_config {
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
      * definition in the DSDT
      */
-    unsigned int infop;
+    unsigned long infop;
 
     /* RSDP address */
-    unsigned int rsdp;
+    unsigned long rsdp;
 
     /* x86-specific parameters */
     uint16_t (*lapic_id)(unsigned cpu);
@@ -93,7 +102,7 @@ struct acpi_config {
     uint8_t ioapic_id;
 };
 
-void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
+int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
 
 #endif /* __LIBACPI_H__ */
 
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 1f3b40f..ee32bc7 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -75,7 +75,21 @@ else
 LIBXL_OBJS-y += libxl_no_colo.o
 endif
 
-LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
+ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
+ACPI_FILES = dsdt_pvh.c
+ACPI_OBJS  = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
+$(ACPI_FILES): acpi
+$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
+vpath build.c $(ACPI_PATH)/
+vpath static_tables.c $(ACPI_PATH)/
+LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
+
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
+-include 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_NetBSD),y)
@@ -167,6 +181,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
 $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
 
 libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
+libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
 
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
@@ -309,6 +324,7 @@ clean:
 	$(RM) -f testidl.c.new testidl.c *.api-ok
 	$(RM) -f xenlight.pc
 	$(RM) -f xlutil.pc
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
 
 distclean: clean
 	$(RM) -f xenlight.pc.in xlutil.pc.in
diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index 253a037..7a70b01 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -66,6 +66,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
 
+int libxl__dom_load_acpi(libxl__gc *gc,
+			 const libxl_domain_build_info *b_info,
+			 struct xc_dom_image *dom);
 #endif
 
 #endif
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 2b221aa..d10b04b 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -8,15 +8,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
                                       xc_domain_configuration_t *xc_config)
 {
 
-    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
-        d_config->b_info.device_model_version !=
-        LIBXL_DEVICE_MODEL_VERSION_NONE) {
-        /* HVM domains with a device model. */
-        xc_config->emulation_flags = XEN_X86_EMU_ALL;
-    } else {
-        /* PV or HVM domains without a device model. */
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+        if (d_config->b_info.device_model_version !=
+            LIBXL_DEVICE_MODEL_VERSION_NONE) {
+            xc_config->emulation_flags = XEN_X86_EMU_ALL;
+        } else if (libxl_defbool_val(d_config->b_info.u.hvm.apic)) {
+            /*
+             * HVM guests without device model may want
+             * to have LAPIC emulation.
+             */
+            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
+        }
+    } else 
         xc_config->emulation_flags = 0;
-    }
 
     return 0;
 }
@@ -366,7 +370,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
                                                libxl_domain_build_info *info,
                                                struct xc_dom_image *dom)
 {
-    return 0;
+    int ret = 0;
+
+    if ((info->type == LIBXL_DOMAIN_TYPE_HVM) &&
+        (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE)) {
+        if ( (ret = libxl__dom_load_acpi(gc, info, dom)) != 0 )
+            LOGE(ERROR, "libxl_dom_load_acpi failed");
+    }
+
+    return ret;
 }
 
 /* Return 0 on success, ERROR_* on failure. */
diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libxl/libxl_x86_acpi.c
new file mode 100644
index 0000000..97c7d42
--- /dev/null
+++ b/tools/libxl/libxl_x86_acpi.c
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "libxl_internal.h"
+#include "libxl_arch.h"
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/e820.h>
+#include "libacpi/libacpi.h"
+
+#include <xc_dom.h>
+
+ /* Number of pages holding ACPI tables */
+#define NUM_ACPI_PAGES 16
+/* Store RSDP in the last 64 bytes of BIOS RO memory */
+#define RSDP_ADDRESS (0x100000 - 64)
+#define ACPI_INFO_PHYSICAL_ADDRESS 0xfc000000
+
+extern const unsigned char dsdt_pvh[];
+extern const unsigned int dsdt_pvh_len;
+
+/* Assumes contiguous physical space */
+static unsigned long virt_to_phys(struct acpi_ctxt *ctxt, void *v)
+{
+    return (((unsigned long)v - ctxt->alloc_base_vaddr) +
+            ctxt->alloc_base_paddr);
+}
+
+static void *mem_alloc(struct acpi_ctxt *ctxt,
+                       uint32_t size, uint32_t align)
+{
+    unsigned long s, e;
+
+    /* Align to at least 16 bytes. */
+    if (align < 16)
+        align = 16;
+
+    s = (ctxt->alloc_currp + align) & ~((unsigned long)align - 1);
+    e = s + size - 1;
+
+    /* TODO: Reallocate memory */
+    if ((e < s) || (e >= ctxt->alloc_end))
+        return NULL;
+
+    while (ctxt->alloc_currp >> ctxt->page_shift != 
+           e >> ctxt->page_shift)
+        ctxt->alloc_currp += ctxt->page_size;
+
+    ctxt->alloc_currp = e;
+
+    return (void *)s;
+}
+
+static void acpi_mem_free(struct acpi_ctxt *ctxt,
+                          void *v, uint32_t size)
+{
+}
+
+static uint16_t acpi_lapic_id(unsigned cpu)
+{
+    return cpu * 2;
+}
+
+static int init_acpi_config(libxl__gc *gc, 
+                            struct xc_dom_image *dom,
+                            const libxl_domain_build_info *b_info,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    int i, rc;
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_pvh;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_pvh_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if (rc < 0) {
+        LOG(ERROR, "%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config->hvminfo = libxl__zalloc(gc, sizeof(*config->hvminfo));
+
+    config->hvminfo->apic_mode = libxl_defbool_val(b_info->u.hvm.apic);
+
+    if (dom->nr_vnodes) {
+        unsigned int *vcpu_to_vnode, *vdistance;
+        struct xen_vmemrange *vmemrange;
+        struct acpi_numa *numa = &config->numa;
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &config->hvminfo->nr_vcpus, NULL, NULL, NULL);
+        if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+
+        vmemrange = libxl__zalloc(gc, dom->nr_vmemranges * sizeof(*vmemrange));
+        vdistance = libxl__zalloc(gc, dom->nr_vnodes * sizeof(*vdistance));
+        vcpu_to_vnode = libxl__zalloc(gc, config->hvminfo->nr_vcpus *
+                                             sizeof(*vcpu_to_vnode));
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges, &config->hvminfo->nr_vcpus,
+                                vmemrange, vdistance, vcpu_to_vnode);
+	if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+        numa->vmemrange = vmemrange;
+        numa->vdistance = vdistance;
+        numa->vcpu_to_vnode = vcpu_to_vnode;
+    }
+    else
+        config->hvminfo->nr_vcpus = info.max_vcpu_id + 1;
+
+    for (i=0; i<config->hvminfo->nr_vcpus; i++)
+        config->hvminfo->vcpu_online[i / 8] |= 1 << (i & 7);
+
+
+    config->lapic_base_address = LAPIC_BASE_ADDRESS;
+    config->lapic_id = acpi_lapic_id;
+
+    return 0;
+}
+
+int libxl__dom_load_acpi(libxl__gc *gc,
+                         const libxl_domain_build_info *b_info,
+                         struct xc_dom_image *dom)
+{
+    struct acpi_config config = {0};
+    struct acpi_ctxt ctxt;
+    int rc, acpi_pages_num;
+    void *acpi_pages;
+    unsigned long page_mask;
+
+    if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) ||
+        (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE))
+        return 0;
+
+    ctxt.page_size = XC_DOM_PAGE_SIZE(dom);
+    ctxt.page_shift =  XC_DOM_PAGE_SHIFT(dom);
+    page_mask = (1UL << ctxt.page_shift) - 1;
+
+    ctxt.mem_ops.alloc = mem_alloc;
+    ctxt.mem_ops.v2p = virt_to_phys;
+    ctxt.mem_ops.free = acpi_mem_free;
+
+    rc = init_acpi_config(gc, dom, b_info, &config);
+    if (rc) {
+        LOG(ERROR, "%s: init_acpi_config failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config.rsdp = (unsigned long)libxl__malloc(gc, ctxt.page_size);
+    config.infop = (unsigned long)libxl__malloc(gc, ctxt.page_size);
+    /* Pages to hold ACPI tables */
+    acpi_pages =  libxl__malloc(gc, (NUM_ACPI_PAGES + 1) * ctxt.page_size);
+
+    /*
+     * Set up allocator memory.
+     * Start next to acpi_info page to avoid fracturing e820.
+     */
+    ctxt.alloc_base_paddr = ACPI_INFO_PHYSICAL_ADDRESS + ctxt.page_size;
+    ctxt.alloc_base_vaddr = ctxt.alloc_currp = (unsigned long)acpi_pages;
+    ctxt.alloc_end = (unsigned long)acpi_pages +
+        (NUM_ACPI_PAGES * ctxt.page_size);
+
+    /* Build the tables. */
+    rc = acpi_build_tables(&ctxt, &config);
+    if (rc) {
+        LOG(ERROR, "%s: acpi_build_tables failed with %d",
+            __FUNCTION__, rc);
+        goto out;
+    }
+
+    /* Calculate how many pages are needed for the tables. */
+    acpi_pages_num =
+        ((ctxt.alloc_currp - (unsigned long)acpi_pages) >> ctxt.page_shift) +
+        ((ctxt.alloc_currp & page_mask) ? 1 : 0);
+
+    dom->acpi_modules[0].data = (void *)config.rsdp;
+    dom->acpi_modules[0].length = 64;
+    dom->acpi_modules[0].guest_addr_out = RSDP_ADDRESS;
+
+    dom->acpi_modules[1].data = (void *)config.infop;
+    dom->acpi_modules[1].length = 4096;
+    dom->acpi_modules[1].guest_addr_out = ACPI_INFO_PHYSICAL_ADDRESS;
+
+    dom->acpi_modules[2].data = acpi_pages;
+    dom->acpi_modules[2].length = acpi_pages_num  << ctxt.page_shift;
+    dom->acpi_modules[2].guest_addr_out = ACPI_INFO_PHYSICAL_ADDRESS + ctxt.page_size;
+
+out:
+
+    return rc;
+
+}
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/libxl/libxl_x86_acpi.h b/tools/libxl/libxl_x86_acpi.h
new file mode 100644
index 0000000..17a8bd4
--- /dev/null
+++ b/tools/libxl/libxl_x86_acpi.h
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef LIBXL_X86_ACPI_H
+#define LIBXL_X86_ACPI_H
+
+#include "libxl_internal.h"
+
+#define ASSERT(x) assert(x)
+
+static inline int test_bit(unsigned int b, void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}
+
+#endif /* LIBXL_X_86_ACPI_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.8.3.1


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

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

* [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (17 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests Boris Ostrovsky
@ 2016-09-07 18:59 ` Boris Ostrovsky
  2016-09-15 10:13   ` Wei Liu
  2016-09-14 15:21 ` [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 18:59 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, boris.ostrovsky, roger.pau

Load ACPI modules into guest space

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v3:
* Use more macros in first_high_idx intilalization.
* Format adjustments

 tools/libxc/xc_dom_core.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index ebada89..3817eb8 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -1040,6 +1040,95 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
     return -1;
 }
 
+static int populate_acpi_pages(struct xc_dom_image *dom,
+                               xen_pfn_t *extents,
+                               unsigned int num_pages)
+{
+    int rc;
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    unsigned long idx;
+    unsigned int first_high_idx = (4 << 30) >> PAGE_SHIFT; /* 4GB */
+
+    for ( ; num_pages; num_pages--, extents++ )
+    {
+
+        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
+            continue;
+
+        if (dom->highmem_end)
+        {
+            idx = --dom->highmem_end;
+            if ( idx == first_high_idx )
+                dom->highmem_end = 0;
+        }
+        else
+            idx = --dom->lowmem_end;
+
+        rc = xc_domain_add_to_physmap(xch, domid,
+                                      XENMAPSPACE_gmfn,
+                                      idx, *extents);
+        if (rc)
+            return rc;
+    }
+
+    return 0;
+}
+
+static int xc_dom_load_acpi(struct xc_dom_image *dom)
+{
+    int j, i = 0;
+    unsigned num_pages;
+    xen_pfn_t *extents, base;
+    void *ptr;
+
+    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
+    {
+        DOMPRINTF("%s: %d bytes at address %" PRIx64 "\n", __FUNCTION__,
+                  dom->acpi_modules[i].length,
+                  dom->acpi_modules[i].guest_addr_out);
+
+        num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
+                       XC_PAGE_SHIFT;
+        extents = malloc(num_pages * sizeof(*extents));
+        if ( !extents )
+        {
+            DOMPRINTF("%s: Out of memory", __FUNCTION__);
+            goto err;
+        }
+
+        base = dom->acpi_modules[i].guest_addr_out >> XC_PAGE_SHIFT;
+        for (j=0; j<num_pages; j++)
+            extents[j] = base + j;
+        if ( populate_acpi_pages(dom, extents, num_pages) )
+        {
+            DOMPRINTF("%s: Can populate ACPI pages", __FUNCTION__);
+            goto err;
+        }
+
+        ptr = xc_map_foreign_range(dom->xch, dom->guest_domid,
+                                      XC_PAGE_SIZE * num_pages,
+                                      PROT_READ | PROT_WRITE, base);
+        if ( !ptr )
+        {
+            DOMPRINTF("%s: Can't map %d pages at 0x%lx",
+                      __FUNCTION__, num_pages, base);
+            goto err;
+        }
+
+        memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+
+        free(extents);
+        i++;
+    }
+
+    return 0;
+
+err:
+    free(extents);
+    return -1;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;
@@ -1097,6 +1186,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
+    /* load ACPI tables */
+    if ( xc_dom_load_acpi(dom) != 0 )
+        goto err;
+
     /* allocate other pages */
     if ( !dom->arch_hooks->p2m_base_supported ||
          dom->parms.p2m_base >= dom->parms.virt_base ||
-- 
1.8.3.1


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

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

* Re: [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
  2016-09-07 18:59 ` [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
@ 2016-09-07 19:48   ` Boris Ostrovsky
  0 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-07 19:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Lars Kurth, Kevin Tian, wei.liu2, Kouya Shimura, andrew.cooper3,
	ian.jackson, julien.grall, Simon Horman, keke, jbeulich,
	zhaoshenglong, Stefan Berger, Keir Fraser, Daniel Kiper,
	roger.pau

Adding Lenovo.

On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
> ACPI builder is currently distributed under GPLv2 license.
>
> We plan to make the builder available to components other
> than the hvmloader (which is also GPLv2). Some of these
> components (such as libxl) may be distributed under LGPL-2.1
> so that they can be used by non-GPLv2 callers.  But this
> will not be possible if we incorporate the ACPI builder in
> those other components.
>
> To avoid this problem we are relicensing sources in ACPI
> bulder directory to the Lesser GNU Public License (LGPL)
> version 2.1
>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Acked-by: Daniel Kiper <dkiper@net-space.pl>
> Acked-by: Stefan Berger <stefanb@us.ibm.com>
> Acked-by: Kouya Shimura <kouya@jp.fujitsu.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> Acked-by: Kevin Tian <kevin.tian@intel.com>
> Acked-by: Keir Fraser <keir@xen.org>
> Acked-by: Simon Horman <horms@verge.net.au>
> Acked-by: Lars Kurth <lars.kurth@citrix.com>
> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> CC: Daniel Kiper <dkiper@net-space.pl>
> CC: Stefan Berger <stefanb@us.ibm.com>
> CC: Kouya Shimura <kouya@jp.fujitsu.com>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Kevin Tian <kevin.tian@intel.com>
> CC: Keir Fraser <keir@xen.org>
> CC: Simon Horman <horms@verge.net.au>
> CC: Lars Kurth <lars.kurth@citrix.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>
> * Stll missing Lenovo ACK for commit 801d469ad8b2b88f669326327df03d03200efbfb
>
>  tools/firmware/hvmloader/acpi/Makefile        | 18 ++++++++----------
>  tools/firmware/hvmloader/acpi/acpi2_0.h       | 19 ++++++++-----------
>  tools/firmware/hvmloader/acpi/build.c         | 18 ++++++++----------
>  tools/firmware/hvmloader/acpi/dsdt.asl        | 18 ++++++++----------
>  tools/firmware/hvmloader/acpi/mk_dsdt.c       | 12 ++++++++++++
>  tools/firmware/hvmloader/acpi/ssdt_pm.asl     | 11 ++++-------
>  tools/firmware/hvmloader/acpi/ssdt_s3.asl     | 11 ++++-------
>  tools/firmware/hvmloader/acpi/ssdt_s4.asl     | 11 ++++-------
>  tools/firmware/hvmloader/acpi/ssdt_tpm.asl    | 18 ++++++++----------
>  tools/firmware/hvmloader/acpi/static_tables.c | 18 ++++++++----------
>  10 files changed, 72 insertions(+), 82 deletions(-)
>
> diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/firmware/hvmloader/acpi/Makefile
> index d3e882a..703d67b 100644
> --- a/tools/firmware/hvmloader/acpi/Makefile
> +++ b/tools/firmware/hvmloader/acpi/Makefile
> @@ -1,17 +1,15 @@
>  #
>  # Copyright (c) 2004, Intel Corporation.
>  #
> -# This program is free software; you can redistribute it and/or modify it
> -# under the terms and conditions of the GNU General Public License,
> -# version 2, as published by the Free Software Foundation.
> +# 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 it will be useful, but WITHOUT
> -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> -# more details.
> -#
> -# You should have received a copy of the GNU General Public License along with
> -# this program; If not, see <http://www.gnu.org/licenses/>.
> +# 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
> +# NU Lesser General Public License for more details.
>  #
>  
>  XEN_ROOT = $(CURDIR)/../../../..
> diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h b/tools/firmware/hvmloader/acpi/acpi2_0.h
> index 87a558a..775eb7a 100644
> --- a/tools/firmware/hvmloader/acpi/acpi2_0.h
> +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h
> @@ -1,18 +1,15 @@
>  /*
>   * Copyright (c) 2004, Intel Corporation.
>   *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms and conditions of the GNU General Public License,
> - * version 2, as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along with
> - * this program; If not, see <http://www.gnu.org/licenses/>.
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU Lesser General Public License as published
> + * by the Free Software Foundation; version 2.1 only. with the special
> + * exception on linking described in file LICENSE.
>   *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
>   */
>  #ifndef _ACPI_2_0_H_
>  #define _ACPI_2_0_H_
> diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
> index dccddff..de56f1f 100644
> --- a/tools/firmware/hvmloader/acpi/build.c
> +++ b/tools/firmware/hvmloader/acpi/build.c
> @@ -2,17 +2,15 @@
>   * Copyright (c) 2004, Intel Corporation.
>   * Copyright (c) 2006, Keir Fraser, XenSource Inc.
>   *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms and conditions of the GNU General Public License, version 
> - * 2, as published by the Free Software Foundation.
> + * 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 it will be useful, but WITHOUT ANY 
> - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
> - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
> - * details.
> - *
> - * You should have received a copy of the GNU General Public License along with
> - * this program; If not, see <http://www.gnu.org/licenses/>.
> + * 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 "acpi2_0.h"
> diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl
> index bd65823..895a8e5 100644
> --- a/tools/firmware/hvmloader/acpi/dsdt.asl
> +++ b/tools/firmware/hvmloader/acpi/dsdt.asl
> @@ -3,17 +3,15 @@
>   *
>   * Copyright (c) 2004, Intel Corporation.
>   *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms and conditions of the GNU General Public License,
> - * version 2, as published by the Free Software Foundation.
> + * 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 it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along with
> - * this program; If not, see <http://www.gnu.org/licenses/>.
> + * 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.
>   */
>  
>  DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
> diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c b/tools/firmware/hvmloader/acpi/mk_dsdt.c
> index b2ade89..bc414bf 100644
> --- a/tools/firmware/hvmloader/acpi/mk_dsdt.c
> +++ b/tools/firmware/hvmloader/acpi/mk_dsdt.c
> @@ -1,3 +1,15 @@
> +/*
> + * 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 <stdio.h>
>  #include <stdarg.h>
>  #include <stdint.h>
> diff --git a/tools/firmware/hvmloader/acpi/ssdt_pm.asl b/tools/firmware/hvmloader/acpi/ssdt_pm.asl
> index 1a7d752..d81b1f2 100644
> --- a/tools/firmware/hvmloader/acpi/ssdt_pm.asl
> +++ b/tools/firmware/hvmloader/acpi/ssdt_pm.asl
> @@ -5,17 +5,14 @@
>   * Copyright (c) 2008  Citrix Systems, Inc.
>   *
>   * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> + * 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 General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; If not, see <http://www.gnu.org/licenses/>.
> + * GNU Lesser General Public License for more details.
>   */
>  
>  /*
> diff --git a/tools/firmware/hvmloader/acpi/ssdt_s3.asl b/tools/firmware/hvmloader/acpi/ssdt_s3.asl
> index f89ac02..c83bbbf 100644
> --- a/tools/firmware/hvmloader/acpi/ssdt_s3.asl
> +++ b/tools/firmware/hvmloader/acpi/ssdt_s3.asl
> @@ -4,17 +4,14 @@
>   * Copyright (c) 2011  Citrix Systems, Inc.
>   *
>   * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> + * 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 General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; If not, see <http://www.gnu.org/licenses/>.
> + * GNU Lesser General Public License for more details.
>   */
>  
>  DefinitionBlock ("SSDT_S3.aml", "SSDT", 2, "Xen", "HVM", 0)
> diff --git a/tools/firmware/hvmloader/acpi/ssdt_s4.asl b/tools/firmware/hvmloader/acpi/ssdt_s4.asl
> index d589e4b..325ac11 100644
> --- a/tools/firmware/hvmloader/acpi/ssdt_s4.asl
> +++ b/tools/firmware/hvmloader/acpi/ssdt_s4.asl
> @@ -4,17 +4,14 @@
>   * Copyright (c) 2011  Citrix Systems, Inc.
>   *
>   * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> + * 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 General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; If not, see <http://www.gnu.org/licenses/>.
> + * GNU Lesser General Public License for more details.
>   */
>  
>  DefinitionBlock ("SSDT_S4.aml", "SSDT", 2, "Xen", "HVM", 0)
> diff --git a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl
> index 2ae8ad4..a0fb1fd 100644
> --- a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl
> +++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl
> @@ -3,17 +3,15 @@
>   *
>   * Copyright (c) 2006, IBM Corporation.
>   *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms and conditions of the GNU General Public License,
> - * version 2, as published by the Free Software Foundation.
> + * 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 it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along with
> - * this program; If not, see <http://www.gnu.org/licenses/>.
> + * 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.
>   */
>  
>  /* SSDT for TPM TIS Interface for Xen with Qemu device model. */
> diff --git a/tools/firmware/hvmloader/acpi/static_tables.c b/tools/firmware/hvmloader/acpi/static_tables.c
> index f4d627b..617bf68 100644
> --- a/tools/firmware/hvmloader/acpi/static_tables.c
> +++ b/tools/firmware/hvmloader/acpi/static_tables.c
> @@ -2,17 +2,15 @@
>   * Copyright (c) 2004, Intel Corporation.
>   * Copyright (c) 2006, Keir Fraser, XenSource Inc.
>   *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms and conditions of the GNU General Public License,
> - * version 2, as published by the Free Software Foundation.
> + * 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 it will be useful, but WITHOUT
> - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> - * more details.
> - *
> - * You should have received a copy of the GNU General Public License along with
> - * this program; If not, see <http://www.gnu.org/licenses/>.
> + * 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 "acpi2_0.h"


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

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

* Re: [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader
  2016-09-07 18:59 ` [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader Boris Ostrovsky
@ 2016-09-08 13:41   ` Jan Beulich
  0 siblings, 0 replies; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 13:41 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> Changes in v3:
> * Constified acpi_numa's pointers
> * Constified acpi_config call parameter where possible

Thanks, but how about ...

> --- a/tools/firmware/hvmloader/acpi/build.c
> +++ b/tools/firmware/hvmloader/acpi/build.c
> @@ -70,18 +70,20 @@ static void set_checksum(
>      p[checksum_offset] = -sum;
>  }
>  
> -static struct acpi_20_madt *construct_madt(struct acpi_info *info)
> +static struct acpi_20_madt *construct_madt(const struct acpi_config *config,
> +                                           struct acpi_info *info)
>  {
>      struct acpi_20_madt           *madt;
>      struct acpi_20_madt_intsrcovr *intsrcovr;
>      struct acpi_20_madt_ioapic    *io_apic;
>      struct acpi_20_madt_lapic     *lapic;
> +    struct hvm_info_table         *hvminfo = config->hvminfo;

... this?

> --- a/tools/firmware/hvmloader/acpi/libacpi.h
> +++ b/tools/firmware/hvmloader/acpi/libacpi.h
> @@ -20,6 +20,8 @@
>  #ifndef __LIBACPI_H__
>  #define __LIBACPI_H__
>  
> +#include <xen/memory.h>

Why? struct xen_vmemrange doesn't get instantiated anywhere in
this header.

> @@ -49,6 +59,9 @@ struct acpi_config {
>          uint32_t length;
>      } pt;
>  
> +    struct acpi_numa numa;
> +    struct hvm_info_table *hvminfo;

And this cannot be const?

Jan


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

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

* Re: [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops
  2016-09-07 18:59 ` [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops Boris Ostrovsky
@ 2016-09-08 13:54   ` Jan Beulich
  0 siblings, 0 replies; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 13:54 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> Components that wish to use ACPI builder will need to provide their own
> mem_alloc() and virt_to_phys() routines. Pointers to these routines will
> be passed to the builder as memory ops.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

Albeit I'd prefer if ...

> --- a/tools/firmware/hvmloader/util.c
> +++ b/tools/firmware/hvmloader/util.c
> @@ -866,10 +866,27 @@ static uint8_t battery_port_exists(void)
>      return (inb(0x88) == 0x1F);
>  }
>  
> +static unsigned long acpi_v2p(struct acpi_ctxt *ctxt, void *v)
> +{
> +    return virt_to_phys(v);
> +}
> +
> +static void *acpi_mem_alloc(struct acpi_ctxt *ctxt,
> +                            uint32_t size, uint32_t align)
> +{
> +    return mem_alloc(size, align);
> +}
> +
> +static void acpi_mem_free(struct acpi_ctxt *ctxt,
> +                          void *v, uint32_t size)
> +{
> +}

... the body of this function was actually a brief comment,
clarifying why this does nothing.

Jan


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

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

* Re: [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly
  2016-09-07 18:59 ` [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly Boris Ostrovsky
@ 2016-09-08 13:56   ` Jan Beulich
  0 siblings, 0 replies; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 13:56 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> ACPI sources will be available to various component which will build
> them according to their own rules. ACPI's Makefile will only generate
> necessary source files.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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


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

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

* Re: [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments
  2016-09-07 18:59 ` [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments Boris Ostrovsky
@ 2016-09-08 14:05   ` Jan Beulich
  2016-09-08 18:29     ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 14:05 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> In prepearation to moving acpi sources into generally available
> libacpi:
> 
> 1. Pass IOAPIC/LAPIC/PCI mask values via struct acpi_config
> 2. Modify include files search paths to point to acpi directory
> 3. Macro-ise include file for build.c that defines various
>    utilities used by that file. Users of libacpi will be expected
>    to define this macro when compiling build.c
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
> Changes in v3:
> * Instead of adding x86.h pass APIC/IOAPIC info via acpi_config parameter.
> * Use <> instead of "" for include directive
> 
> 
>  tools/firmware/hvmloader/Makefile             |  3 ++-
>  tools/firmware/hvmloader/acpi/README          | 16 ++++++++++++----
>  tools/firmware/hvmloader/acpi/build.c         | 19 ++++++++++---------
>  tools/firmware/hvmloader/acpi/libacpi.h       |  7 +++++++
>  tools/firmware/hvmloader/hvmloader.c          |  2 +-
>  tools/firmware/hvmloader/rombios.c            |  2 +-
>  tools/firmware/hvmloader/seabios.c            |  5 +++--
>  tools/firmware/hvmloader/util.c               | 15 +++++++++++++--
>  tools/firmware/rombios/32bit/Makefile         |  2 +-
>  tools/firmware/rombios/32bit/tcgbios/Makefile |  2 +-
>  tools/firmware/rombios/32bit/util.h           |  2 +-
>  11 files changed, 52 insertions(+), 23 deletions(-)
> 
> diff --git a/tools/firmware/hvmloader/Makefile 
> b/tools/firmware/hvmloader/Makefile
> index b6c5b83..77e95f1 100644
> --- a/tools/firmware/hvmloader/Makefile
> +++ b/tools/firmware/hvmloader/Makefile
> @@ -76,7 +76,8 @@ smbios.o: CFLAGS += 
> -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
>  ACPI_PATH = acpi
>  ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
>  ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
> -$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
> +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"../util.h\"
> +CFLAGS += -I$(ACPI_PATH)
>  vpath build.c $(ACPI_PATH)
>  vpath static_tables.c $(ACPI_PATH)
>  OBJS += $(ACPI_OBJS)
> diff --git a/tools/firmware/hvmloader/acpi/README 
> b/tools/firmware/hvmloader/acpi/README
> index 210d5ba..2b9d6e1 100644
> --- a/tools/firmware/hvmloader/acpi/README
> +++ b/tools/firmware/hvmloader/acpi/README
> @@ -1,11 +1,19 @@
> -ACPI Table for domain firmware
> +ACPI builder for domain firmware
>  
>  
> -INSTALL
> +BUILDING ACPI
>  -----------------
> -Simply make is OK.
> -# make 
> +Users of ACPI builder are expected to provide an include file that makes 
> available
> +the following:
> +* strncpy
> +* printf
> +* NULL
> +* test_bit
> +* offsetof
>  
> +When compiling build.c, the name of this include file should be given to
> +compiler as -DLIBACPI_STDUTILS=\"<filename>\". See 
> tools/firmware/hvmloader/Makefile
> +for an example.
>  
>  Note on DSDT Table
>  ------------------
> diff --git a/tools/firmware/hvmloader/acpi/build.c 
> b/tools/firmware/hvmloader/acpi/build.c
> index 2098920..1cd640d 100644
> --- a/tools/firmware/hvmloader/acpi/build.c
> +++ b/tools/firmware/hvmloader/acpi/build.c
> @@ -13,15 +13,13 @@
>   * GNU Lesser General Public License for more details.
>   */
>  
> +#include LIBACPI_STDUTILS
>  #include "acpi2_0.h"
>  #include "libacpi.h"
>  #include "ssdt_s3.h"
>  #include "ssdt_s4.h"
>  #include "ssdt_tpm.h"
>  #include "ssdt_pm.h"
> -#include "../config.h"
> -#include "../util.h"
> -#include "../vnuma.h"
>  #include <xen/hvm/hvm_xs_strings.h>
>  #include <xen/hvm/params.h>
>  
> @@ -81,6 +79,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt 
> *ctxt,
>      struct hvm_info_table         *hvminfo = config->hvminfo;
>      int i, sz;
>  
> +    if ( config->lapic_id == NULL )
> +        return NULL;
> +
>      sz  = sizeof(struct acpi_20_madt);
>      sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
>      sz += sizeof(struct acpi_20_madt_ioapic);
> @@ -97,7 +98,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt 
> *ctxt,
>      madt->header.oem_revision = ACPI_OEM_REVISION;
>      madt->header.creator_id   = ACPI_CREATOR_ID;
>      madt->header.creator_revision = ACPI_CREATOR_REVISION;
> -    madt->lapic_addr = LAPIC_BASE_ADDRESS;
> +    madt->lapic_addr = config->lapic_base_address;
>      madt->flags      = ACPI_PCAT_COMPAT;
>  
>      if ( config->table_flags & ACPI_HAS_IOAPIC )
> @@ -116,7 +117,7 @@ static struct acpi_20_madt *construct_madt(struct 
> acpi_ctxt *ctxt,
>                  intsrcovr->gsi    = 2;
>                  intsrcovr->flags  = 0x0;
>              }
> -            else if ( PCI_ISA_IRQ_MASK & (1U << i) )
> +            else if ( config->pci_isa_irq_mask & (1U << i) )
>              {
>                  /* PCI: active-low level-triggered. */
>                  intsrcovr->gsi    = i;
> @@ -135,8 +136,8 @@ static struct acpi_20_madt *construct_madt(struct 
> acpi_ctxt *ctxt,
>          memset(io_apic, 0, sizeof(*io_apic));
>          io_apic->type        = ACPI_IO_APIC;
>          io_apic->length      = sizeof(*io_apic);
> -        io_apic->ioapic_id   = IOAPIC_ID;
> -        io_apic->ioapic_addr = ioapic_base_address;
> +        io_apic->ioapic_id   = config->ioapic_id;
> +        io_apic->ioapic_addr = config->ioapic_base_address;
>  
>          lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
>      }
> @@ -152,7 +153,7 @@ static struct acpi_20_madt *construct_madt(struct 
> acpi_ctxt *ctxt,
>          lapic->length  = sizeof(*lapic);
>          /* Processor ID must match processor-object IDs in the DSDT. */
>          lapic->acpi_processor_id = i;
> -        lapic->apic_id = LAPIC_ID(i);
> +        lapic->apic_id = config->lapic_id(i);
>          lapic->flags = (test_bit(i, hvminfo->vcpu_online)
>                          ? ACPI_LOCAL_APIC_ENABLED : 0);
>          lapic++;
> @@ -240,7 +241,7 @@ static struct acpi_20_srat *construct_srat(struct 
> acpi_ctxt *ctxt,
>          processor->type     = ACPI_PROCESSOR_AFFINITY;
>          processor->length   = sizeof(*processor);
>          processor->domain   = config->numa.vcpu_to_vnode[i];
> -        processor->apic_id  = LAPIC_ID(i);
> +        processor->apic_id  = config->lapic_id(i);
>          processor->flags    = ACPI_LOCAL_APIC_AFFIN_ENABLED;
>          processor++;
>      }
> diff --git a/tools/firmware/hvmloader/acpi/libacpi.h 
> b/tools/firmware/hvmloader/acpi/libacpi.h
> index 3bcd226..d803139 100644
> --- a/tools/firmware/hvmloader/acpi/libacpi.h
> +++ b/tools/firmware/hvmloader/acpi/libacpi.h
> @@ -84,6 +84,13 @@ struct acpi_config {
>  
>      /* RSDP address */
>      unsigned int rsdp;
> +
> +    /* x86-specific parameters */
> +    uint16_t (*lapic_id)(unsigned cpu);

Why uint16_t? Legacy APIC IDs in MADT are in an 8-bit field, and
x2APIC IDs require 32 bits. Depending on whether we want to be
able to re-use the same function for x2APIC support (once that
gets added) the return type should change accordingly. (But if we
were to re-use it, I guess a second parameter would then also be
needed.)

And then - down the road you're not planning to build a shared
library using this interface? Otherwise we'd need to consider some
compatibility aspects.

Jan

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

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

* Re: [PATCH v3 12/19] libacpi: Build DSDT for PVH guests
  2016-09-07 18:59 ` [PATCH v3 12/19] libacpi: Build DSDT for PVH guests Boris Ostrovsky
@ 2016-09-08 14:09   ` Jan Beulich
  2016-09-14  4:13   ` Shannon Zhao
  1 sibling, 0 replies; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 14:09 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> @@ -32,15 +32,22 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
>  $(MK_DSDT): mk_dsdt.c
>  	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
>  
> -$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl $(MK_DSDT)
> +$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
>  	awk 'NR > 1 {print s} {s=$$0}' $< > $@
> +	cat dsdt_acpi_info.asl >> $@
>  	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
>  
>  # NB. awk invocation is a portable alternative to 'head -n -1'
> -$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl $(MK_DSDT)
> +$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
>  	awk 'NR > 1 {print s} {s=$$0}' $< > $@
> +	cat dsdt_acpi_info.asl >> $@
>  	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
>  
> +$(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
> +	printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@
> +	cat dsdt_acpi_info.asl >> $@
> +	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@

Hadn't I seen you switch to use intermediate files with all this output
redirection in v2? Did that get lost, or do I misremember?

Everything else looks fine.

Jan


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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-07 18:59 ` [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts Boris Ostrovsky
@ 2016-09-08 14:15   ` Jan Beulich
  2016-09-08 18:51     ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 14:15 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> Intermediate stages of building a target should be made with
> temporary files that are copied to final target in the end.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
> New in v3

Ah, here we go.

> --- a/tools/libacpi/Makefile
> +++ b/tools/libacpi/Makefile
> @@ -21,38 +21,45 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>  C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
>  H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
>  
> +ifeq ($(subst all,,$(MAKECMDGOALS)),)
> +TDIR := $(shell mktemp -d --tmpdir=$(TMPDIR) tmp_XXXXXX)
> +endif

How is this (or really the rules using this directory) supposed to work
when other than "all" gets built?

>  vpath iasl $(PATH)
>  all: $(C_SRC) $(H_SRC)
> +	rm -fr $(TDIR)

And how is the temporary directory going to get cleaned up when
interrupting make? I think you really should use a subdirectory
underneath the build directory, which then can stay there until
"make clean". And then you can also use mv instead of cp below,
or even move-if-changed.

Jan


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

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

* Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-07 18:59 ` [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests Boris Ostrovsky
@ 2016-09-08 14:20   ` Jan Beulich
  2016-09-08 18:53     ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-08 14:20 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
> Changes in v3:
> * Some constification of call parameters
> * Format adjustments
> * New acpi_mem_free hook (a nop)
> * Changes in init_acpi_config() to deal with constified acpi_numa's
>   pointers (initialize pointers as temp variabales)
> * Add '-include acpi' directive in Makefile to make sure acpi
>   target is built before build.o dependencies are processed
>   (specifically, ssdt_*.h files need to exist)
> 
> 
>  .gitignore                   |  12 ++-
>  tools/libacpi/build.c        |   7 +-
>  tools/libacpi/libacpi.h      |  15 ++-
>  tools/libxl/Makefile         |  18 +++-
>  tools/libxl/libxl_arch.h     |   3 +
>  tools/libxl/libxl_x86.c      |  30 ++++--
>  tools/libxl/libxl_x86_acpi.c | 218 
> +++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/libxl_x86_acpi.h |  35 +++++++
>  8 files changed, 318 insertions(+), 20 deletions(-)
>  create mode 100644 tools/libxl/libxl_x86_acpi.c
>  create mode 100644 tools/libxl/libxl_x86_acpi.h
> 
> diff --git a/.gitignore b/.gitignore
> index 9b2c405..9f5bd8c 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -173,15 +173,19 @@ tools/include/xen/*
>  tools/include/xen-xsm/*
>  tools/include/xen-foreign/*.(c|h|size)
>  tools/include/xen-foreign/checker
> -tools/libxl/libxlu_cfg_y.output
> +tools/libxl/_libxl.api-for-check
> +tools/libxl/*.api-ok
>  tools/libxl/*.pc
>  tools/libxl/*.pc.in
> -tools/libxl/xl
> +tools/libxl/dsdt*.c
> +tools/libxl/dsdt_*.asl
> +tools/libxl/libxlu_cfg_y.output
> +tools/libxl/mk_dsdt
> +tools/libxl/ssdt_*.h
>  tools/libxl/testenum
>  tools/libxl/testenum.c
>  tools/libxl/tmp.*
> -tools/libxl/_libxl.api-for-check
> -tools/libxl/*.api-ok
> +tools/libxl/xl
>  tools/misc/cpuperf/cpuperf-perfcntr
>  tools/misc/cpuperf/cpuperf-xen
>  tools/misc/xc_shadow
> diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
> index 1cd640d..ee5f779 100644
> --- a/tools/libacpi/build.c
> +++ b/tools/libacpi/build.c
> @@ -20,6 +20,7 @@
>  #include "ssdt_s4.h"
>  #include "ssdt_tpm.h"
>  #include "ssdt_pm.h"
> +#include <xen/hvm/hvm_info_table.h>
>  #include <xen/hvm/hvm_xs_strings.h>
>  #include <xen/hvm/params.h>
>  
> @@ -495,7 +496,7 @@ static int new_vm_gid(struct acpi_ctxt *ctxt,
>      return 1;
>  }
>  
> -void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
> +int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
>  {
>      struct acpi_info *acpi_info;
>      struct acpi_20_rsdp *rsdp;
> @@ -630,11 +631,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct 
> acpi_config *config)
>      if ( !new_vm_gid(ctxt, config, acpi_info) )
>          goto oom;
>  
> -    return;
> +    return 0;
>  
>  oom:
>      printf("unable to build ACPI tables: out of memory\n");
> -
> +    return -1;
>  }
>  
>  /*
> diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h
> index d803139..b0ff5aa 100644
> --- a/tools/libacpi/libacpi.h
> +++ b/tools/libacpi/libacpi.h
> @@ -48,6 +48,15 @@ struct acpi_ctxt {
>          void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
>          unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
>      } mem_ops;
> +
> +    unsigned int page_size;
> +    unsigned int page_shift;
> +
> +    /* Memory allocator */
> +    unsigned long alloc_base_paddr;
> +    unsigned long alloc_base_vaddr;
> +    unsigned long alloc_currp;
> +    unsigned long alloc_end;
>  };

There not being (or getting added) any users of these in libacpi/, I
wonder how this is related to the subject of the patch. If this is
data that only libxl needs for its own purposes, then surely this
shouldn't get added to struct acpi_ctxt, but should be a libxl
private extension of that structure.

Jan


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

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

* Re: [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments
  2016-09-08 14:05   ` Jan Beulich
@ 2016-09-08 18:29     ` Boris Ostrovsky
  0 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-08 18:29 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/08/2016 10:05 AM, Jan Beulich wrote:
>>
>> diff --git a/tools/firmware/hvmloader/acpi/libacpi.h 
>> b/tools/firmware/hvmloader/acpi/libacpi.h
>> index 3bcd226..d803139 100644
>> --- a/tools/firmware/hvmloader/acpi/libacpi.h
>> +++ b/tools/firmware/hvmloader/acpi/libacpi.h
>> @@ -84,6 +84,13 @@ struct acpi_config {
>>  
>>      /* RSDP address */
>>      unsigned int rsdp;
>> +
>> +    /* x86-specific parameters */
>> +    uint16_t (*lapic_id)(unsigned cpu);
> Why uint16_t? Legacy APIC IDs in MADT are in an 8-bit field, and
> x2APIC IDs require 32 bits. Depending on whether we want to be
> able to re-use the same function for x2APIC support (once that
> gets added) the return type should change accordingly. (But if we
> were to re-use it, I guess a second parameter would then also be
> needed.)

No good reason for uint16_t, should be uint8_t.

I think deciding on how interface will look for x2APIC should be
deferred until when we support it.

>
> And then - down the road you're not planning to build a shared
> library using this interface? Otherwise we'd need to consider some
> compatibility aspects.

No specific plans for now, the objects are expected to be built and
linked directly to whoever wants to use this (so libacpi is somewhat of
a misnomer, similar to libelf).


-boris


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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-08 14:15   ` Jan Beulich
@ 2016-09-08 18:51     ` Boris Ostrovsky
  2016-09-09  8:03       ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-08 18:51 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>> Intermediate stages of building a target should be made with
>> temporary files that are copied to final target in the end.
>>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> ---
>> New in v3
> Ah, here we go.
>
>> --- a/tools/libacpi/Makefile
>> +++ b/tools/libacpi/Makefile
>> @@ -21,38 +21,45 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>>  C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
>>  H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
>>  
>> +ifeq ($(subst all,,$(MAKECMDGOALS)),)
>> +TDIR := $(shell mktemp -d --tmpdir=$(TMPDIR) tmp_XXXXXX)
>> +endif
> How is this (or really the rules using this directory) supposed to work
> when other than "all" gets built?


I realize it's a somewhat weak argument but only 'all' and 'clean'
targets are supposed to be used. In fact I was thinking about explicitly
making a check for targets.


>
>>  vpath iasl $(PATH)
>>  all: $(C_SRC) $(H_SRC)
>> +	rm -fr $(TDIR)
> And how is the temporary directory going to get cleaned up when
> interrupting make? I think you really should use a subdirectory
> underneath the build directory, which then can stay there until
> "make clean". And then you can also use mv instead of cp below,
> or even move-if-changed.

The reason I am doing this in /tmp and use tmp_XXXXX as template is
because I found that at least one old versions of iasl has a bug where
it can't process path that has a '.' in it. It drops anything after the
dot, presumably because it thinks it's file suffix.

This is true on fedora12 (2009), which is what we still use as build
environment. I know that fedora 18 doesn't have this problem but I don't
know at which point this got fixed. (Interestingly enough, I tried to
build from F12's sources for iasl and could not reproduce this. Now, i
built with new tools so perhaps the bug is not in iasl itself but in
something like yacc, which is used for the build).

I don't think we have any requirement on supported iasl version so I am
not sure we can ignore this error.

-boris




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

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

* Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-08 14:20   ` Jan Beulich
@ 2016-09-08 18:53     ` Boris Ostrovsky
  2016-09-09  8:05       ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-08 18:53 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/08/2016 10:20 AM, Jan Beulich wrote:
>>
>>  
>>  /*
>> diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h
>> index d803139..b0ff5aa 100644
>> --- a/tools/libacpi/libacpi.h
>> +++ b/tools/libacpi/libacpi.h
>> @@ -48,6 +48,15 @@ struct acpi_ctxt {
>>          void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
>>          unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
>>      } mem_ops;
>> +
>> +    unsigned int page_size;
>> +    unsigned int page_shift;
>> +
>> +    /* Memory allocator */
>> +    unsigned long alloc_base_paddr;
>> +    unsigned long alloc_base_vaddr;
>> +    unsigned long alloc_currp;
>> +    unsigned long alloc_end;
>>  };
> There not being (or getting added) any users of these in libacpi/, I
> wonder how this is related to the subject of the patch. If this is
> data that only libxl needs for its own purposes, then surely this
> shouldn't get added to struct acpi_ctxt, but should be a libxl
> private extension of that structure.

struct acpi_ctxt {
    ...

    void *private;
};

?

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-08 18:51     ` Boris Ostrovsky
@ 2016-09-09  8:03       ` Jan Beulich
  2016-09-09 13:07         ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-09  8:03 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>> --- a/tools/libacpi/Makefile
>>> +++ b/tools/libacpi/Makefile
>>> @@ -21,38 +21,45 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>>>  C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  
> dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
>>>  H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h 
> ssdt_tpm.h)
>>>  
>>> +ifeq ($(subst all,,$(MAKECMDGOALS)),)
>>> +TDIR := $(shell mktemp -d --tmpdir=$(TMPDIR) tmp_XXXXXX)
>>> +endif
>> How is this (or really the rules using this directory) supposed to work
>> when other than "all" gets built?
> 
> 
> I realize it's a somewhat weak argument but only 'all' and 'clean'
> targets are supposed to be used. In fact I was thinking about explicitly
> making a check for targets.

Hmm, that would be quite limiting in case one wants to analyze a
problem with just a single build step. (On the hypervisor side I,
every once in a while, find it helpful to be able to compile individual
files into .o, or even produce the intermediate .i or .s.)

>>>  vpath iasl $(PATH)
>>>  all: $(C_SRC) $(H_SRC)
>>> +	rm -fr $(TDIR)
>> And how is the temporary directory going to get cleaned up when
>> interrupting make? I think you really should use a subdirectory
>> underneath the build directory, which then can stay there until
>> "make clean". And then you can also use mv instead of cp below,
>> or even move-if-changed.
> 
> The reason I am doing this in /tmp and use tmp_XXXXX as template is
> because I found that at least one old versions of iasl has a bug where
> it can't process path that has a '.' in it. It drops anything after the
> dot, presumably because it thinks it's file suffix.

That . is a leading one, as in ./path/file.ext? If so, why can't this be
made path/file.ext? The leading ./ shouldn't be necessary after all.

Also this part of your answer doesn't address the cleanup aspect at
all. (And btw., thinking about it again I don't see the need for a
subdirectory. We have ample room to name the intermediate files
suitably without causing any name collision.)

> This is true on fedora12 (2009), which is what we still use as build
> environment. I know that fedora 18 doesn't have this problem but I don't
> know at which point this got fixed. (Interestingly enough, I tried to
> build from F12's sources for iasl and could not reproduce this. Now, i
> built with new tools so perhaps the bug is not in iasl itself but in
> something like yacc, which is used for the build).
> 
> I don't think we have any requirement on supported iasl version so I am
> not sure we can ignore this error.

I agree.

Jan


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

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

* Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-08 18:53     ` Boris Ostrovsky
@ 2016-09-09  8:05       ` Jan Beulich
  2016-09-09 13:11         ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-09  8:05 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 08.09.16 at 20:53, <boris.ostrovsky@oracle.com> wrote:
> On 09/08/2016 10:20 AM, Jan Beulich wrote:
>>> --- a/tools/libacpi/libacpi.h
>>> +++ b/tools/libacpi/libacpi.h
>>> @@ -48,6 +48,15 @@ struct acpi_ctxt {
>>>          void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
>>>          unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
>>>      } mem_ops;
>>> +
>>> +    unsigned int page_size;
>>> +    unsigned int page_shift;
>>> +
>>> +    /* Memory allocator */
>>> +    unsigned long alloc_base_paddr;
>>> +    unsigned long alloc_base_vaddr;
>>> +    unsigned long alloc_currp;
>>> +    unsigned long alloc_end;
>>>  };
>> There not being (or getting added) any users of these in libacpi/, I
>> wonder how this is related to the subject of the patch. If this is
>> data that only libxl needs for its own purposes, then surely this
>> shouldn't get added to struct acpi_ctxt, but should be a libxl
>> private extension of that structure.
> 
> struct acpi_ctxt {
>     ...
> 
>     void *private;
> };
> 
> ?

That's one option; I'd prefer

struct libxl_acpi_ctxt {
    struct acpi_ctxt ctxt;
    ...
};

though, together with whatever equivalent to container_of() exists
in libxl.

Jan


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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09  8:03       ` Jan Beulich
@ 2016-09-09 13:07         ` Boris Ostrovsky
  2016-09-09 13:29           ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 13:07 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/09/2016 04:03 AM, Jan Beulich wrote:
>>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
>> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>>> --- a/tools/libacpi/Makefile
>>>> +++ b/tools/libacpi/Makefile
>>>> @@ -21,38 +21,45 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>>>>  C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  
>> dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
>>>>  H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h 
>> ssdt_tpm.h)
>>>>  
>>>> +ifeq ($(subst all,,$(MAKECMDGOALS)),)
>>>> +TDIR := $(shell mktemp -d --tmpdir=$(TMPDIR) tmp_XXXXXX)
>>>> +endif
>>> How is this (or really the rules using this directory) supposed to work
>>> when other than "all" gets built?
>>
>> I realize it's a somewhat weak argument but only 'all' and 'clean'
>> targets are supposed to be used. In fact I was thinking about explicitly
>> making a check for targets.
> Hmm, that would be quite limiting in case one wants to analyze a
> problem with just a single build step. (On the hypervisor side I,
> every once in a while, find it helpful to be able to compile individual
> files into .o, or even produce the intermediate .i or .s.)

Yes.

I tried to figure out a way for Makefile to always execute a rule when
before it exits but didn't find anything. You can do it as a *first*
rule (with "-include <file>") but not as a final one.

My only defense here (again, pretty weak) is that making libacpi 'all'
target is pretty fast.

>
>>>>  vpath iasl $(PATH)
>>>>  all: $(C_SRC) $(H_SRC)
>>>> +	rm -fr $(TDIR)
>>> And how is the temporary directory going to get cleaned up when
>>> interrupting make? I think you really should use a subdirectory
>>> underneath the build directory, which then can stay there until
>>> "make clean". And then you can also use mv instead of cp below,
>>> or even move-if-changed.
>> The reason I am doing this in /tmp and use tmp_XXXXX as template is
>> because I found that at least one old versions of iasl has a bug where
>> it can't process path that has a '.' in it. It drops anything after the
>> dot, presumably because it thinks it's file suffix.
> That . is a leading one, as in ./path/file.ext? If so, why can't this be
> made path/file.ext? The leading ./ shouldn't be necessary after all.

No, not a leading one. Inside a name:

Expected:

[root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
[root@ovs104 libacpi]# iasl -vs -p /tmp/root/xen.git/dsdt_anycpu -tc
/tmp/dsdt_anycpu.asl &>/dev/null
[root@ovs104 libacpi]# ls -R /tmp/root/
/tmp/root/:
xen.git

/tmp/root/xen.git:
dsdt_anycpu.aml  dsdt_anycpu.hex
[root@ovs104 libacpi]#


Fedora 12:

[root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
[root@ovs104 libacpi]# ~/iasl.f12 -vs -p /tmp/root/xen.git/dsdt_anycpu
-tc /tmp/dsdt_anycpu.asl &>/dev/null
[root@ovs104 libacpi]# ls -R /tmp/root/
/tmp/root/:
xen.aml  xen.git  xen.hex

/tmp/root/xen.git:
[root@ovs104 libacpi]#

I tried escaping the dot, putting path in quotes, etc. but without any
success.

>
> Also this part of your answer doesn't address the cleanup aspect at
> all.

Again, not the greatest way to deal with this, but we will leave temp
directory in /tmp on interrupts. (And on error I could have added an
error handling target but decided not to do that so that it's easier to
debug the error).


>  (And btw., thinking about it again I don't see the need for a
> subdirectory. We have ample room to name the intermediate files
> suitably without causing any name collision.)

That, in fact, is what I initially had --- I just added an extra temp
suffix to intermediate files during a build. And right before sending
the series I figured I'd give it a spin on our build server. Big mistake!

So I agree that this is not the best solution but I haven't come up with
anything better.

-boris


>
>> This is true on fedora12 (2009), which is what we still use as build
>> environment. I know that fedora 18 doesn't have this problem but I don't
>> know at which point this got fixed. (Interestingly enough, I tried to
>> build from F12's sources for iasl and could not reproduce this. Now, i
>> built with new tools so perhaps the bug is not in iasl itself but in
>> something like yacc, which is used for the build).
>>
>> I don't think we have any requirement on supported iasl version so I am
>> not sure we can ignore this error.
> I agree.
>
> Jan
>



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

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

* Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-09  8:05       ` Jan Beulich
@ 2016-09-09 13:11         ` Boris Ostrovsky
  2016-09-09 13:50           ` Ian Jackson
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 13:11 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/09/2016 04:05 AM, Jan Beulich wrote:
>>>> On 08.09.16 at 20:53, <boris.ostrovsky@oracle.com> wrote:
>> On 09/08/2016 10:20 AM, Jan Beulich wrote:
>>>> --- a/tools/libacpi/libacpi.h
>>>> +++ b/tools/libacpi/libacpi.h
>>>> @@ -48,6 +48,15 @@ struct acpi_ctxt {
>>>>          void (*free)(struct acpi_ctxt *ctxt, void *v, uint32_t size);
>>>>          unsigned long (*v2p)(struct acpi_ctxt *ctxt, void *v);
>>>>      } mem_ops;
>>>> +
>>>> +    unsigned int page_size;
>>>> +    unsigned int page_shift;
>>>> +
>>>> +    /* Memory allocator */
>>>> +    unsigned long alloc_base_paddr;
>>>> +    unsigned long alloc_base_vaddr;
>>>> +    unsigned long alloc_currp;
>>>> +    unsigned long alloc_end;
>>>>  };
>>> There not being (or getting added) any users of these in libacpi/, I
>>> wonder how this is related to the subject of the patch. If this is
>>> data that only libxl needs for its own purposes, then surely this
>>> shouldn't get added to struct acpi_ctxt, but should be a libxl
>>> private extension of that structure.
>> struct acpi_ctxt {
>>     ...
>>
>>     void *private;
>> };
>>
>> ?
> That's one option; I'd prefer
>
> struct libxl_acpi_ctxt {
>     struct acpi_ctxt ctxt;
>     ...
> };
>
> though, together with whatever equivalent to container_of() exists
> in libxl.

Yes, this is better. I don't see it defined in libxl but I can define
one myself.

-boris


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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 13:07         ` Boris Ostrovsky
@ 2016-09-09 13:29           ` Jan Beulich
  2016-09-09 13:56             ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-09 13:29 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 09.09.16 at 15:07, <boris.ostrovsky@oracle.com> wrote:
> On 09/09/2016 04:03 AM, Jan Beulich wrote:
>>>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
>>> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>>>>  vpath iasl $(PATH)
>>>>>  all: $(C_SRC) $(H_SRC)
>>>>> +	rm -fr $(TDIR)
>>>> And how is the temporary directory going to get cleaned up when
>>>> interrupting make? I think you really should use a subdirectory
>>>> underneath the build directory, which then can stay there until
>>>> "make clean". And then you can also use mv instead of cp below,
>>>> or even move-if-changed.
>>> The reason I am doing this in /tmp and use tmp_XXXXX as template is
>>> because I found that at least one old versions of iasl has a bug where
>>> it can't process path that has a '.' in it. It drops anything after the
>>> dot, presumably because it thinks it's file suffix.
>> That . is a leading one, as in ./path/file.ext? If so, why can't this be
>> made path/file.ext? The leading ./ shouldn't be necessary after all.
> 
> No, not a leading one. Inside a name:
> 
> Expected:
> 
> [root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
> [root@ovs104 libacpi]# iasl -vs -p /tmp/root/xen.git/dsdt_anycpu -tc

Then my suggestion of using relative paths would still help?

>>  (And btw., thinking about it again I don't see the need for a
>> subdirectory. We have ample room to name the intermediate files
>> suitably without causing any name collision.)
> 
> That, in fact, is what I initially had --- I just added an extra temp
> suffix to intermediate files during a build. And right before sending
> the series I figured I'd give it a spin on our build server. Big mistake!

Big mistake? You leave me curious, but unable guess.

Jan


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

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

* Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-09 13:11         ` Boris Ostrovsky
@ 2016-09-09 13:50           ` Ian Jackson
  2016-09-09 14:02             ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Ian Jackson @ 2016-09-09 13:50 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

Boris Ostrovsky writes ("Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests"):
> On 09/09/2016 04:05 AM, Jan Beulich wrote:
> > struct libxl_acpi_ctxt {
> >     struct acpi_ctxt ctxt;
> >     ...
> > };
> >
> > though, together with whatever equivalent to container_of() exists
> > in libxl.
> 
> Yes, this is better. I don't see it defined in libxl but I can define
> one myself.

It's called CONTAINER_OF.  See tools/libxl/CODING_STYLE, and/or the
output of something like `git grep -i contain tools/libxl'.

Thanks,
Ian.

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 13:29           ` Jan Beulich
@ 2016-09-09 13:56             ` Boris Ostrovsky
  2016-09-09 14:13               ` Ian Jackson
  2016-09-09 15:20               ` Jan Beulich
  0 siblings, 2 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 13:56 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/09/2016 09:29 AM, Jan Beulich wrote:
>>>> On 09.09.16 at 15:07, <boris.ostrovsky@oracle.com> wrote:
>> On 09/09/2016 04:03 AM, Jan Beulich wrote:
>>>>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
>>>> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>>>>>  vpath iasl $(PATH)
>>>>>>  all: $(C_SRC) $(H_SRC)
>>>>>> +	rm -fr $(TDIR)
>>>>> And how is the temporary directory going to get cleaned up when
>>>>> interrupting make? I think you really should use a subdirectory
>>>>> underneath the build directory, which then can stay there until
>>>>> "make clean". And then you can also use mv instead of cp below,
>>>>> or even move-if-changed.
>>>> The reason I am doing this in /tmp and use tmp_XXXXX as template is
>>>> because I found that at least one old versions of iasl has a bug where
>>>> it can't process path that has a '.' in it. It drops anything after the
>>>> dot, presumably because it thinks it's file suffix.
>>> That . is a leading one, as in ./path/file.ext? If so, why can't this be
>>> made path/file.ext? The leading ./ shouldn't be necessary after all.
>> No, not a leading one. Inside a name:
>>
>> Expected:
>>
>> [root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
>> [root@ovs104 libacpi]# iasl -vs -p /tmp/root/xen.git/dsdt_anycpu -tc
> Then my suggestion of using relative paths would still help?

Apparently it doesn't like any dots:

[root@ovs104 /]# mkdir -p /tmp/root/foo
[root@ovs104 /]# mkdir -p /tmp/root/bar
[root@ovs104 /]# cd /tmp/root/foo/
[root@ovs104 foo]# ls -aR /tmp/root/
/tmp/root/:
.  ..  bar  foo

/tmp/root/bar:
.  ..

/tmp/root/foo:
.  ..
[root@ovs104 foo]# ~/iasl.f12 -vs -p "../bar/dsdt_anycpu" -tc
/tmp/dsdt_anycpu.asl &>/dev/null
[root@ovs104 foo]# ls -aR /tmp/root/
/tmp/root/:
.  ..  bar  foo

/tmp/root/bar:
.  ..

/tmp/root/foo:
.  ..  ..aml  ..hex
[root@ovs104 foo]#


-boris

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

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

* Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-09 13:50           ` Ian Jackson
@ 2016-09-09 14:02             ` Boris Ostrovsky
  0 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 14:02 UTC (permalink / raw)
  To: Ian Jackson
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

On 09/09/2016 09:50 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests"):
>> On 09/09/2016 04:05 AM, Jan Beulich wrote:
>>> struct libxl_acpi_ctxt {
>>>     struct acpi_ctxt ctxt;
>>>     ...
>>> };
>>>
>>> though, together with whatever equivalent to container_of() exists
>>> in libxl.
>> Yes, this is better. I don't see it defined in libxl but I can define
>> one myself.
> It's called CONTAINER_OF.  See tools/libxl/CODING_STYLE, and/or the
> output of something like `git grep -i contain tools/libxl'.

Ah, thanks. I haven't thought of running git grep.

-boris

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 13:56             ` Boris Ostrovsky
@ 2016-09-09 14:13               ` Ian Jackson
  2016-09-09 14:31                 ` Boris Ostrovsky
  2016-09-09 15:20               ` Jan Beulich
  1 sibling, 1 reply; 71+ messages in thread
From: Ian Jackson @ 2016-09-09 14:13 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):
> On 09/09/2016 09:29 AM, Jan Beulich wrote:
> > Then my suggestion of using relative paths would still help?
> 
> Apparently it doesn't like any dots:
...
> [root@ovs104 foo]# ~/iasl.f12 -vs -p "../bar/dsdt_anycpu" -tc
> /tmp/dsdt_anycpu.asl &>/dev/null
> [root@ovs104 foo]# ls -aR /tmp/root/
> /tmp/root/:
> .  ..  bar  foo
> 
> /tmp/root/bar:
> .  ..
> 
> /tmp/root/foo:
> .  ..  ..aml  ..hex
> [root@ovs104 foo]#

This seems to suggest that it looks for the last dot, not the first
one.

If you provide a filename which has an "extension", as it seems to
expect, does it DTRT ?

Ian.

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 14:13               ` Ian Jackson
@ 2016-09-09 14:31                 ` Boris Ostrovsky
  2016-09-09 14:33                   ` Ian Jackson
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 14:31 UTC (permalink / raw)
  To: Ian Jackson
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

On 09/09/2016 10:13 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):
>> On 09/09/2016 09:29 AM, Jan Beulich wrote:
>>> Then my suggestion of using relative paths would still help?
>> Apparently it doesn't like any dots:
> ...
>> [root@ovs104 foo]# ~/iasl.f12 -vs -p "../bar/dsdt_anycpu" -tc
>> /tmp/dsdt_anycpu.asl &>/dev/null
>> [root@ovs104 foo]# ls -aR /tmp/root/
>> /tmp/root/:
>> .  ..  bar  foo
>>
>> /tmp/root/bar:
>> .  ..
>>
>> /tmp/root/foo:
>> .  ..  ..aml  ..hex
>> [root@ovs104 foo]#
> This seems to suggest that it looks for the last dot, not the first
> one.
>
> If you provide a filename which has an "extension", as it seems to
> expect, does it DTRT ?

Indeed!

In fact, I can just append a dot to the name:

[root@ovs104 tmp]# mkdir -p /tmp/root/xen.git
[root@ovs104 tmp]# ~/iasl.f12 -vs -p /tmp/root/xen.git/dsdt_anycpu -tc
/tmp/dsdt_anycpu.asl &>/dev/null
[root@ovs104 tmp]# ls -aR /tmp/root/
/tmp/root/:
.  ..  xen.aml  xen.git  xen.hex

/tmp/root/xen.git:
.  ..
[root@ovs104 tmp]# ~/iasl.f12 -vs -p /tmp/root/xen.git/dsdt_anycpu. -tc
/tmp/dsdt_anycpu.asl &>/dev/null
[root@ovs104 tmp]# ls -aR /tmp/root/
/tmp/root/:
.  ..  xen.aml  xen.git  xen.hex

/tmp/root/xen.git:
.  ..  dsdt_anycpu.aml  dsdt_anycpu.hex
[root@ovs104 tmp]#


With that I can go back to my original version where I don't need to
have a temp directory at all.

Thanks Ian.

-boris

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 14:31                 ` Boris Ostrovsky
@ 2016-09-09 14:33                   ` Ian Jackson
  2016-09-09 14:38                     ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Ian Jackson @ 2016-09-09 14:33 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):
> In fact, I can just append a dot to the name:

I think it would be less weird to append a dot and then an actual
extension with some letters or something.  I'm not sure what the
extension ought to be but just a dot is going to be weird and
confusing.

Ian.

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 14:33                   ` Ian Jackson
@ 2016-09-09 14:38                     ` Boris Ostrovsky
  0 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 14:38 UTC (permalink / raw)
  To: Ian Jackson
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

On 09/09/2016 10:33 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):
>> In fact, I can just append a dot to the name:
> I think it would be less weird to append a dot and then an actual
> extension with some letters or something.  I'm not sure what the
> extension ought to be but just a dot is going to be weird and
> confusing.

Yes, I will append some sort of a suffix and add a comment explaining
why it is needed.

-boris

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 13:56             ` Boris Ostrovsky
  2016-09-09 14:13               ` Ian Jackson
@ 2016-09-09 15:20               ` Jan Beulich
  2016-09-09 16:05                 ` Boris Ostrovsky
  1 sibling, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-09 15:20 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 09.09.16 at 15:56, <boris.ostrovsky@oracle.com> wrote:
> On 09/09/2016 09:29 AM, Jan Beulich wrote:
>>>>> On 09.09.16 at 15:07, <boris.ostrovsky@oracle.com> wrote:
>>> On 09/09/2016 04:03 AM, Jan Beulich wrote:
>>>>>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
>>>>> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>>>>>>  vpath iasl $(PATH)
>>>>>>>  all: $(C_SRC) $(H_SRC)
>>>>>>> +	rm -fr $(TDIR)
>>>>>> And how is the temporary directory going to get cleaned up when
>>>>>> interrupting make? I think you really should use a subdirectory
>>>>>> underneath the build directory, which then can stay there until
>>>>>> "make clean". And then you can also use mv instead of cp below,
>>>>>> or even move-if-changed.
>>>>> The reason I am doing this in /tmp and use tmp_XXXXX as template is
>>>>> because I found that at least one old versions of iasl has a bug where
>>>>> it can't process path that has a '.' in it. It drops anything after the
>>>>> dot, presumably because it thinks it's file suffix.
>>>> That . is a leading one, as in ./path/file.ext? If so, why can't this be
>>>> made path/file.ext? The leading ./ shouldn't be necessary after all.
>>> No, not a leading one. Inside a name:
>>>
>>> Expected:
>>>
>>> [root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
>>> [root@ovs104 libacpi]# iasl -vs -p /tmp/root/xen.git/dsdt_anycpu -tc
>> Then my suggestion of using relative paths would still help?
> 
> Apparently it doesn't like any dots:
> 
> [root@ovs104 /]# mkdir -p /tmp/root/foo
> [root@ovs104 /]# mkdir -p /tmp/root/bar
> [root@ovs104 /]# cd /tmp/root/foo/
> [root@ovs104 foo]# ls -aR /tmp/root/
> /tmp/root/:
> .  ..  bar  foo
> 
> /tmp/root/bar:
> .  ..
> 
> /tmp/root/foo:
> .  ..
> [root@ovs104 foo]# ~/iasl.f12 -vs -p "../bar/dsdt_anycpu" -tc

Why would you need to use ../ ?

Jan


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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 15:20               ` Jan Beulich
@ 2016-09-09 16:05                 ` Boris Ostrovsky
  2016-09-09 16:11                   ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-09 16:05 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/09/2016 11:20 AM, Jan Beulich wrote:
>>>> On 09.09.16 at 15:56, <boris.ostrovsky@oracle.com> wrote:
>> On 09/09/2016 09:29 AM, Jan Beulich wrote:
>>>>>> On 09.09.16 at 15:07, <boris.ostrovsky@oracle.com> wrote:
>>>> On 09/09/2016 04:03 AM, Jan Beulich wrote:
>>>>>>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
>>>>>> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>>>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>>>>>>>  vpath iasl $(PATH)
>>>>>>>>  all: $(C_SRC) $(H_SRC)
>>>>>>>> +	rm -fr $(TDIR)
>>>>>>> And how is the temporary directory going to get cleaned up when
>>>>>>> interrupting make? I think you really should use a subdirectory
>>>>>>> underneath the build directory, which then can stay there until
>>>>>>> "make clean". And then you can also use mv instead of cp below,
>>>>>>> or even move-if-changed.
>>>>>> The reason I am doing this in /tmp and use tmp_XXXXX as template is
>>>>>> because I found that at least one old versions of iasl has a bug where
>>>>>> it can't process path that has a '.' in it. It drops anything after the
>>>>>> dot, presumably because it thinks it's file suffix.
>>>>> That . is a leading one, as in ./path/file.ext? If so, why can't this be
>>>>> made path/file.ext? The leading ./ shouldn't be necessary after all.
>>>> No, not a leading one. Inside a name:
>>>>
>>>> Expected:
>>>>
>>>> [root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
>>>> [root@ovs104 libacpi]# iasl -vs -p /tmp/root/xen.git/dsdt_anycpu -tc
>>> Then my suggestion of using relative paths would still help?
>> Apparently it doesn't like any dots:
>>
>> [root@ovs104 /]# mkdir -p /tmp/root/foo
>> [root@ovs104 /]# mkdir -p /tmp/root/bar
>> [root@ovs104 /]# cd /tmp/root/foo/
>> [root@ovs104 foo]# ls -aR /tmp/root/
>> /tmp/root/:
>> .  ..  bar  foo
>>
>> /tmp/root/bar:
>> .  ..
>>
>> /tmp/root/foo:
>> .  ..
>> [root@ovs104 foo]# ~/iasl.f12 -vs -p "../bar/dsdt_anycpu" -tc
> Why would you need to use ../ ?


Didn't you ask to test with a relative path?

(Not this this is needed anymore, now that Ian suggested a solution).

-boris

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

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

* Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts
  2016-09-09 16:05                 ` Boris Ostrovsky
@ 2016-09-09 16:11                   ` Jan Beulich
  0 siblings, 0 replies; 71+ messages in thread
From: Jan Beulich @ 2016-09-09 16:11 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 09.09.16 at 18:05, <boris.ostrovsky@oracle.com> wrote:
> On 09/09/2016 11:20 AM, Jan Beulich wrote:
>>>>> On 09.09.16 at 15:56, <boris.ostrovsky@oracle.com> wrote:
>>> On 09/09/2016 09:29 AM, Jan Beulich wrote:
>>>>>>> On 09.09.16 at 15:07, <boris.ostrovsky@oracle.com> wrote:
>>>>> On 09/09/2016 04:03 AM, Jan Beulich wrote:
>>>>>>>>> On 08.09.16 at 20:51, <boris.ostrovsky@oracle.com> wrote:
>>>>>>> On 09/08/2016 10:15 AM, Jan Beulich wrote:
>>>>>>>>>>> On 07.09.16 at 20:59, <boris.ostrovsky@oracle.com> wrote:
>>>>>>>>>  vpath iasl $(PATH)
>>>>>>>>>  all: $(C_SRC) $(H_SRC)
>>>>>>>>> +	rm -fr $(TDIR)
>>>>>>>> And how is the temporary directory going to get cleaned up when
>>>>>>>> interrupting make? I think you really should use a subdirectory
>>>>>>>> underneath the build directory, which then can stay there until
>>>>>>>> "make clean". And then you can also use mv instead of cp below,
>>>>>>>> or even move-if-changed.
>>>>>>> The reason I am doing this in /tmp and use tmp_XXXXX as template is
>>>>>>> because I found that at least one old versions of iasl has a bug where
>>>>>>> it can't process path that has a '.' in it. It drops anything after the
>>>>>>> dot, presumably because it thinks it's file suffix.
>>>>>> That . is a leading one, as in ./path/file.ext? If so, why can't this be
>>>>>> made path/file.ext? The leading ./ shouldn't be necessary after all.
>>>>> No, not a leading one. Inside a name:
>>>>>
>>>>> Expected:
>>>>>
>>>>> [root@ovs104 libacpi]# mkdir -p /tmp/root/xen.git
>>>>> [root@ovs104 libacpi]# iasl -vs -p /tmp/root/xen.git/dsdt_anycpu -tc
>>>> Then my suggestion of using relative paths would still help?
>>> Apparently it doesn't like any dots:
>>>
>>> [root@ovs104 /]# mkdir -p /tmp/root/foo
>>> [root@ovs104 /]# mkdir -p /tmp/root/bar
>>> [root@ovs104 /]# cd /tmp/root/foo/
>>> [root@ovs104 foo]# ls -aR /tmp/root/
>>> /tmp/root/:
>>> .  ..  bar  foo
>>>
>>> /tmp/root/bar:
>>> .  ..
>>>
>>> /tmp/root/foo:
>>> .  ..
>>> [root@ovs104 foo]# ~/iasl.f12 -vs -p "../bar/dsdt_anycpu" -tc
>> Why would you need to use ../ ?
> 
> 
> Didn't you ask to test with a relative path?

Yes, and I gave an example of what I meant: dir/name.ext; no
./ or ../ or alike.

Jan


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

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

* Re: [PATCH v3 12/19] libacpi: Build DSDT for PVH guests
  2016-09-07 18:59 ` [PATCH v3 12/19] libacpi: Build DSDT for PVH guests Boris Ostrovsky
  2016-09-08 14:09   ` Jan Beulich
@ 2016-09-14  4:13   ` Shannon Zhao
  2016-09-14 12:47     ` Boris Ostrovsky
  1 sibling, 1 reply; 71+ messages in thread
From: Shannon Zhao @ 2016-09-14  4:13 UTC (permalink / raw)
  To: Boris Ostrovsky, xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich, roger.pau



On 2016/9/8 2:59, Boris Ostrovsky wrote:
> PVH guests require DSDT with only ACPI INFO (Xen-specific) and Processor
> objects. We separate ASL's ACPI INFO definition into dsdt_acpi_info.asl so
> that it can be included in ASLs for both HVM and PVH2.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
> Changes in v3:
> * Added comment to dsdt_acpi_info.asl indicating that the structure
>   there must match struct acpi_info
> * Use QEMU_NONE in mk_dsdt.c
> * Makefile tweaks
> 
>  tools/libacpi/Makefile           | 13 ++++++++++---
>  tools/libacpi/dsdt.asl           | 20 --------------------
>  tools/libacpi/dsdt_acpi_info.asl | 26 ++++++++++++++++++++++++++
>  tools/libacpi/mk_dsdt.c          |  8 ++++++++
>  4 files changed, 44 insertions(+), 23 deletions(-)
>  create mode 100644 tools/libacpi/dsdt_acpi_info.asl
> 
> diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
> index 6325cd0..12b081e 100644
> --- a/tools/libacpi/Makefile
> +++ b/tools/libacpi/Makefile
> @@ -18,7 +18,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
>  MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>  
>  # Sources to be generated
> -C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
> +C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
>  H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
>  
Hi Bros,

It looks like you forgot to add 'C_SRC-$(CONFIG_X86)' here. Will you add
it in your next version?

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v3 12/19] libacpi: Build DSDT for PVH guests
  2016-09-14  4:13   ` Shannon Zhao
@ 2016-09-14 12:47     ` Boris Ostrovsky
  0 siblings, 0 replies; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-14 12:47 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich, roger.pau

On 09/14/2016 12:13 AM, Shannon Zhao wrote:
>
> On 2016/9/8 2:59, Boris Ostrovsky wrote:
>> PVH guests require DSDT with only ACPI INFO (Xen-specific) and Processor
>> objects. We separate ASL's ACPI INFO definition into dsdt_acpi_info.asl so
>> that it can be included in ASLs for both HVM and PVH2.
>>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> ---
>> Changes in v3:
>> * Added comment to dsdt_acpi_info.asl indicating that the structure
>>   there must match struct acpi_info
>> * Use QEMU_NONE in mk_dsdt.c
>> * Makefile tweaks
>>
>>  tools/libacpi/Makefile           | 13 ++++++++++---
>>  tools/libacpi/dsdt.asl           | 20 --------------------
>>  tools/libacpi/dsdt_acpi_info.asl | 26 ++++++++++++++++++++++++++
>>  tools/libacpi/mk_dsdt.c          |  8 ++++++++
>>  4 files changed, 44 insertions(+), 23 deletions(-)
>>  create mode 100644 tools/libacpi/dsdt_acpi_info.asl
>>
>> diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
>> index 6325cd0..12b081e 100644
>> --- a/tools/libacpi/Makefile
>> +++ b/tools/libacpi/Makefile
>> @@ -18,7 +18,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
>>  MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
>>  
>>  # Sources to be generated
>> -C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
>> +C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
>>  H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
>>  
> Hi Bros,
>
> It looks like you forgot to add 'C_SRC-$(CONFIG_X86)' here. Will you add
> it in your next version?

I know I said that I'd do it but then I realized that it would probably
make more sense to add this macro when a non-x86 target is first
introduced (which I believe is patch 3 in your series). It's a one-line
change IIRC so it shouldn't be too disruptive to your series.

I should have mentioned it when I posted v3 of my patches, I apologize
for forgetting it.

-boris



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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (18 preceding siblings ...)
  2016-09-07 18:59 ` [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space Boris Ostrovsky
@ 2016-09-14 15:21 ` Boris Ostrovsky
  2016-09-15 10:18   ` Wei Liu
  19 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-14 15:21 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, roger.pau

On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
> The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
> hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
>
> This is version 3 of the series, see individual patches for changes. It can
> be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3

Wei, Ian --- are there any comments from the toolstack perspective?

>
> The series is probably still gated by lack of an ACK from Lenovo for the
> relicensing patch (included here as patch 1).
>

So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
(which is the patch from Lenovo) and it only does 2 things (assuming I
parsed ASL correctly):
* Adds _PIC method
* Controls and describes legacy PCI interrupt routing. This
functionality has actually been moved into mk_dsdt.c and so this ASL
code is now generated.

Neither of these two things is used by libxl so technically we may not
need the ACK from Lenovo. OTOH, we may forget about this restriction in
the future and accidentally include those two later.


-boris


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

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

* Re: [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules
  2016-09-07 18:59 ` [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules Boris Ostrovsky
@ 2016-09-15 10:13   ` Wei Liu
  0 siblings, 0 replies; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:13 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Wed, Sep 07, 2016 at 02:59:24PM -0400, Boris Ostrovsky wrote:
> Provide ability to load multiple ACPI modules. Thie feature is needed
> by PVHv2 guests and will be used in subsequent patches.
> 
> We assume that PVHv2 guests do not load their ACPI modules specified
> in the configuration file. We can extend support for that in the future
> if desired.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

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

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

* Re: [PATCH v3 15/19] libxl/acpi: Add ACPI e820 entry
  2016-09-07 18:59 ` [PATCH v3 15/19] libxl/acpi: Add ACPI e820 entry Boris Ostrovsky
@ 2016-09-15 10:13   ` Wei Liu
  0 siblings, 0 replies; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:13 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Wed, Sep 07, 2016 at 02:59:25PM -0400, Boris Ostrovsky wrote:
> Add entry for ACPI tables created for PVHv2 guests to e820 map.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

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

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

* Re: [PATCH v3 16/19] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
  2016-09-07 18:59 ` [PATCH v3 16/19] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests Boris Ostrovsky
@ 2016-09-15 10:13   ` Wei Liu
  0 siblings, 0 replies; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:13 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Wed, Sep 07, 2016 at 02:59:26PM -0400, Boris Ostrovsky wrote:
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

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

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

* Re: [PATCH v3 17/19] ilibxl: Initialize domain build info before calling libxl__domain_make
  2016-09-07 18:59 ` [PATCH v3 17/19] ilibxl: Initialize domain build info before calling libxl__domain_make Boris Ostrovsky
@ 2016-09-15 10:13   ` Wei Liu
  0 siblings, 0 replies; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:13 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Wed, Sep 07, 2016 at 02:59:27PM -0400, Boris Ostrovsky wrote:
> libxl__domain_make() may want to use b_info so we should set defaults
> a little earlier.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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

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

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

* Re: [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space
  2016-09-07 18:59 ` [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space Boris Ostrovsky
@ 2016-09-15 10:13   ` Wei Liu
  0 siblings, 0 replies; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:13 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Wed, Sep 07, 2016 at 02:59:29PM -0400, Boris Ostrovsky wrote:
> Load ACPI modules into guest space
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

Some coding style issues are found.

> ---
> Changes in v3:
> * Use more macros in first_high_idx intilalization.
> * Format adjustments
> 
>  tools/libxc/xc_dom_core.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 93 insertions(+)
> 
> diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
> index ebada89..3817eb8 100644
> --- a/tools/libxc/xc_dom_core.c
> +++ b/tools/libxc/xc_dom_core.c
> @@ -1040,6 +1040,95 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
>      return -1;
>  }
>  
> +static int populate_acpi_pages(struct xc_dom_image *dom,
> +                               xen_pfn_t *extents,
> +                               unsigned int num_pages)
> +{
> +    int rc;
> +    xc_interface *xch = dom->xch;
> +    uint32_t domid = dom->guest_domid;
> +    unsigned long idx;
> +    unsigned int first_high_idx = (4 << 30) >> PAGE_SHIFT; /* 4GB */
> +
> +    for ( ; num_pages; num_pages--, extents++ )
> +    {
> +
> +        if ( xc_domain_populate_physmap(xch, domid, 1, 0, 0, extents) == 1 )
> +            continue;
> +
> +        if (dom->highmem_end)
> +        {
> +            idx = --dom->highmem_end;
> +            if ( idx == first_high_idx )
> +                dom->highmem_end = 0;
> +        }
> +        else
> +            idx = --dom->lowmem_end;
> +

Braces around "else" branch please.

> +        rc = xc_domain_add_to_physmap(xch, domid,
> +                                      XENMAPSPACE_gmfn,
> +                                      idx, *extents);
> +        if (rc)
> +            return rc;
> +    }
> +
> +    return 0;
> +}
> +
> +static int xc_dom_load_acpi(struct xc_dom_image *dom)
> +{
> +    int j, i = 0;
> +    unsigned num_pages;
> +    xen_pfn_t *extents, base;
> +    void *ptr;
> +
> +    while ( (i < MAX_ACPI_MODULES) && dom->acpi_modules[i].length )
> +    {
> +        DOMPRINTF("%s: %d bytes at address %" PRIx64 "\n", __FUNCTION__,
> +                  dom->acpi_modules[i].length,
> +                  dom->acpi_modules[i].guest_addr_out);
> +
> +        num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
> +                       XC_PAGE_SHIFT;
> +        extents = malloc(num_pages * sizeof(*extents));
> +        if ( !extents )
> +        {
> +            DOMPRINTF("%s: Out of memory", __FUNCTION__);
> +            goto err;
> +        }
> +
> +        base = dom->acpi_modules[i].guest_addr_out >> XC_PAGE_SHIFT;
> +        for (j=0; j<num_pages; j++)

Spaces.

> +            extents[j] = base + j;
> +        if ( populate_acpi_pages(dom, extents, num_pages) )
> +        {
> +            DOMPRINTF("%s: Can populate ACPI pages", __FUNCTION__);
> +            goto err;
> +        }
> +
> +        ptr = xc_map_foreign_range(dom->xch, dom->guest_domid,
> +                                      XC_PAGE_SIZE * num_pages,
> +                                      PROT_READ | PROT_WRITE, base);

Indentation.

> +        if ( !ptr )
> +        {
> +            DOMPRINTF("%s: Can't map %d pages at 0x%lx",
> +                      __FUNCTION__, num_pages, base);
> +            goto err;
> +        }
> +
> +        memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
> +
> +        free(extents);
> +        i++;
> +    }
> +
> +    return 0;
> +
> +err:
> +    free(extents);
> +    return -1;
> +}
> +
>  int xc_dom_build_image(struct xc_dom_image *dom)
>  {
>      unsigned int page_size;
> @@ -1097,6 +1186,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
>          memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
>      }
>  
> +    /* load ACPI tables */
> +    if ( xc_dom_load_acpi(dom) != 0 )
> +        goto err;
> +
>      /* allocate other pages */
>      if ( !dom->arch_hooks->p2m_base_supported ||
>           dom->parms.p2m_base >= dom->parms.virt_base ||
> -- 
> 1.8.3.1
> 

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-14 15:21 ` [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
@ 2016-09-15 10:18   ` Wei Liu
  2016-09-15 10:20     ` Julien Grall
  0 siblings, 1 reply; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:18 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Wed, Sep 14, 2016 at 11:21:39AM -0400, Boris Ostrovsky wrote:
> On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
> > The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
> > hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
> >
> > This is version 3 of the series, see individual patches for changes. It can
> > be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3
> 
> Wei, Ian --- are there any comments from the toolstack perspective?
> 
> >
> > The series is probably still gated by lack of an ACK from Lenovo for the
> > relicensing patch (included here as patch 1).
> >
> 
> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
> (which is the patch from Lenovo) and it only does 2 things (assuming I
> parsed ASL correctly):
> * Adds _PIC method
> * Controls and describes legacy PCI interrupt routing. This
> functionality has actually been moved into mk_dsdt.c and so this ASL
> code is now generated.
> 
> Neither of these two things is used by libxl so technically we may not
> need the ACK from Lenovo. OTOH, we may forget about this restriction in
> the future and accidentally include those two later.
> 

This is a risk I would rather not take. As you said, we may forget about
the restriction in the future.

Wei.

> 
> -boris
> 

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 10:18   ` Wei Liu
@ 2016-09-15 10:20     ` Julien Grall
  2016-09-15 10:22       ` Wei Liu
  0 siblings, 1 reply; 71+ messages in thread
From: Julien Grall @ 2016-09-15 10:20 UTC (permalink / raw)
  To: Wei Liu, Boris Ostrovsky
  Cc: Stefano Stabellini, andrew.cooper3, xen.org, xen-devel, jbeulich,
	zhaoshenglong, roger.pau

Hi Wei,

On 15/09/2016 11:18, Wei Liu wrote:
> On Wed, Sep 14, 2016 at 11:21:39AM -0400, Boris Ostrovsky wrote:
>> On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
>>> The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
>>> hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
>>>
>>> This is version 3 of the series, see individual patches for changes. It can
>>> be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3
>>
>> Wei, Ian --- are there any comments from the toolstack perspective?
>>
>>>
>>> The series is probably still gated by lack of an ACK from Lenovo for the
>>> relicensing patch (included here as patch 1).
>>>
>>
>> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
>> (which is the patch from Lenovo) and it only does 2 things (assuming I
>> parsed ASL correctly):
>> * Adds _PIC method
>> * Controls and describes legacy PCI interrupt routing. This
>> functionality has actually been moved into mk_dsdt.c and so this ASL
>> code is now generated.
>>
>> Neither of these two things is used by libxl so technically we may not
>> need the ACK from Lenovo. OTOH, we may forget about this restriction in
>> the future and accidentally include those two later.
>>
>
> This is a risk I would rather not take. As you said, we may forget about
> the restriction in the future.

Does it mean this series may not be in Xen 4.8? If so, this will also 
delay other series such as the ACPI guest support for ARM.

Cheers,

-- 
Julien Grall

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 10:20     ` Julien Grall
@ 2016-09-15 10:22       ` Wei Liu
  2016-09-15 12:39         ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Wei Liu @ 2016-09-15 10:22 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Wei Liu, andrew.cooper3, xen.org, xen-devel,
	jbeulich, zhaoshenglong, Boris Ostrovsky, roger.pau

On Thu, Sep 15, 2016 at 11:20:08AM +0100, Julien Grall wrote:
> Hi Wei,
> 
> On 15/09/2016 11:18, Wei Liu wrote:
> >On Wed, Sep 14, 2016 at 11:21:39AM -0400, Boris Ostrovsky wrote:
> >>On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
> >>>The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
> >>>hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
> >>>
> >>>This is version 3 of the series, see individual patches for changes. It can
> >>>be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3
> >>
> >>Wei, Ian --- are there any comments from the toolstack perspective?
> >>
> >>>
> >>>The series is probably still gated by lack of an ACK from Lenovo for the
> >>>relicensing patch (included here as patch 1).
> >>>
> >>
> >>So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
> >>(which is the patch from Lenovo) and it only does 2 things (assuming I
> >>parsed ASL correctly):
> >>* Adds _PIC method
> >>* Controls and describes legacy PCI interrupt routing. This
> >>functionality has actually been moved into mk_dsdt.c and so this ASL
> >>code is now generated.
> >>
> >>Neither of these two things is used by libxl so technically we may not
> >>need the ACK from Lenovo. OTOH, we may forget about this restriction in
> >>the future and accidentally include those two later.
> >>
> >
> >This is a risk I would rather not take. As you said, we may forget about
> >the restriction in the future.
> 
> Does it mean this series may not be in Xen 4.8? If so, this will also delay
> other series such as the ACPI guest support for ARM.
> 

I would like to see this and the subsequent ARM series in 4.8 -- it is
still possible we get an ack from Lenovo any time, but the issue is out
of our control at the moment. It's just one unfortunate incident in open
source software development. Sigh.

Wei.

> Cheers,
> 
> -- 
> Julien Grall

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 10:22       ` Wei Liu
@ 2016-09-15 12:39         ` Boris Ostrovsky
  2016-09-15 13:48           ` Julien Grall
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-15 12:39 UTC (permalink / raw)
  To: Wei Liu, Julien Grall
  Cc: Stefano Stabellini, andrew.cooper3, xen.org, xen-devel, jbeulich,
	zhaoshenglong, roger.pau

On 09/15/2016 06:22 AM, Wei Liu wrote:
> On Thu, Sep 15, 2016 at 11:20:08AM +0100, Julien Grall wrote:
>> Hi Wei,
>>
>> On 15/09/2016 11:18, Wei Liu wrote:
>>> On Wed, Sep 14, 2016 at 11:21:39AM -0400, Boris Ostrovsky wrote:
>>>> On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
>>>>> The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
>>>>> hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
>>>>>
>>>>> This is version 3 of the series, see individual patches for changes. It can
>>>>> be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3
>>>> Wei, Ian --- are there any comments from the toolstack perspective?
>>>>
>>>>> The series is probably still gated by lack of an ACK from Lenovo for the
>>>>> relicensing patch (included here as patch 1).
>>>>>
>>>> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
>>>> (which is the patch from Lenovo) and it only does 2 things (assuming I
>>>> parsed ASL correctly):
>>>> * Adds _PIC method
>>>> * Controls and describes legacy PCI interrupt routing. This
>>>> functionality has actually been moved into mk_dsdt.c and so this ASL
>>>> code is now generated.
>>>>
>>>> Neither of these two things is used by libxl so technically we may not
>>>> need the ACK from Lenovo. OTOH, we may forget about this restriction in
>>>> the future and accidentally include those two later.
>>>>
>>> This is a risk I would rather not take. As you said, we may forget about
>>> the restriction in the future.
>> Does it mean this series may not be in Xen 4.8? If so, this will also delay
>> other series such as the ACPI guest support for ARM.
>>
> I would like to see this and the subsequent ARM series in 4.8 -- it is
> still possible we get an ack from Lenovo any time, but the issue is out
> of our control at the moment. It's just one unfortunate incident in open
> source software development. Sigh.

One option could be to provide a 'gpl_all' (or some such) target in
libacpi in addition to 'all' and that target will be careful about not
including these small un-ACKed portions of the code.

It will be ugly though.

-boris

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 12:39         ` Boris Ostrovsky
@ 2016-09-15 13:48           ` Julien Grall
  2016-09-15 14:07             ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Julien Grall @ 2016-09-15 13:48 UTC (permalink / raw)
  To: Boris Ostrovsky, Wei Liu
  Cc: Stefano Stabellini, andrew.cooper3, xen.org, xen-devel, jbeulich,
	zhaoshenglong, roger.pau

Hi Boris,

On 15/09/2016 13:39, Boris Ostrovsky wrote:
> On 09/15/2016 06:22 AM, Wei Liu wrote:
>> On Thu, Sep 15, 2016 at 11:20:08AM +0100, Julien Grall wrote:
>>> Hi Wei,
>>>
>>> On 15/09/2016 11:18, Wei Liu wrote:
>>>> On Wed, Sep 14, 2016 at 11:21:39AM -0400, Boris Ostrovsky wrote:
>>>>> On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
>>>>>> The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing
>>>>>> hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
>>>>>>
>>>>>> This is version 3 of the series, see individual patches for changes. It can
>>>>>> be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3
>>>>> Wei, Ian --- are there any comments from the toolstack perspective?
>>>>>
>>>>>> The series is probably still gated by lack of an ACK from Lenovo for the
>>>>>> relicensing patch (included here as patch 1).
>>>>>>
>>>>> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
>>>>> (which is the patch from Lenovo) and it only does 2 things (assuming I
>>>>> parsed ASL correctly):
>>>>> * Adds _PIC method
>>>>> * Controls and describes legacy PCI interrupt routing. This
>>>>> functionality has actually been moved into mk_dsdt.c and so this ASL
>>>>> code is now generated.
>>>>>
>>>>> Neither of these two things is used by libxl so technically we may not
>>>>> need the ACK from Lenovo. OTOH, we may forget about this restriction in
>>>>> the future and accidentally include those two later.
>>>>>
>>>> This is a risk I would rather not take. As you said, we may forget about
>>>> the restriction in the future.
>>> Does it mean this series may not be in Xen 4.8? If so, this will also delay
>>> other series such as the ACPI guest support for ARM.
>>>
>> I would like to see this and the subsequent ARM series in 4.8 -- it is
>> still possible we get an ack from Lenovo any time, but the issue is out
>> of our control at the moment. It's just one unfortunate incident in open
>> source software development. Sigh.
>
> One option could be to provide a 'gpl_all' (or some such) target in
> libacpi in addition to 'all' and that target will be careful about not
> including these small un-ACKed portions of the code.
>
> It will be ugly though.

I agree that it is not nice, but it would help us to get this features 
(and the other ones that depend on it) in Xen 4.8. Otherwise we would 
have to wait another 6 months to get those features.

Cheers,

-- 
Julien Grall

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 13:48           ` Julien Grall
@ 2016-09-15 14:07             ` Boris Ostrovsky
  2016-09-15 14:21               ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-15 14:07 UTC (permalink / raw)
  To: Julien Grall, Wei Liu
  Cc: Stefano Stabellini, andrew.cooper3, xen.org, xen-devel, jbeulich,
	zhaoshenglong, roger.pau

On 09/15/2016 09:48 AM, Julien Grall wrote:
> Hi Boris,
>
> On 15/09/2016 13:39, Boris Ostrovsky wrote:
>> On 09/15/2016 06:22 AM, Wei Liu wrote:
>>> On Thu, Sep 15, 2016 at 11:20:08AM +0100, Julien Grall wrote:
>>>> Hi Wei,
>>>>
>>>> On 15/09/2016 11:18, Wei Liu wrote:
>>>>> On Wed, Sep 14, 2016 at 11:21:39AM -0400, Boris Ostrovsky wrote:
>>>>>> On 09/07/2016 02:59 PM, Boris Ostrovsky wrote:
>>>>>>> The goal here is to build ACPI tables for PVHv2/HVMlite guests
>>>>>>> while reusing existing
>>>>>>> hvmloader's ACPI builder code. The builder is provided as a
>>>>>>> library in tools/libacpi.
>>>>>>>
>>>>>>> This is version 3 of the series, see individual patches for
>>>>>>> changes. It can
>>>>>>> be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v3
>>>>>> Wei, Ian --- are there any comments from the toolstack perspective?
>>>>>>
>>>>>>> The series is probably still gated by lack of an ACK from Lenovo
>>>>>>> for the
>>>>>>> relicensing patch (included here as patch 1).
>>>>>>>
>>>>>> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
>>>>>> (which is the patch from Lenovo) and it only does 2 things
>>>>>> (assuming I
>>>>>> parsed ASL correctly):
>>>>>> * Adds _PIC method
>>>>>> * Controls and describes legacy PCI interrupt routing. This
>>>>>> functionality has actually been moved into mk_dsdt.c and so this ASL
>>>>>> code is now generated.
>>>>>>
>>>>>> Neither of these two things is used by libxl so technically we
>>>>>> may not
>>>>>> need the ACK from Lenovo. OTOH, we may forget about this
>>>>>> restriction in
>>>>>> the future and accidentally include those two later.
>>>>>>
>>>>> This is a risk I would rather not take. As you said, we may forget
>>>>> about
>>>>> the restriction in the future.
>>>> Does it mean this series may not be in Xen 4.8? If so, this will
>>>> also delay
>>>> other series such as the ACPI guest support for ARM.
>>>>
>>> I would like to see this and the subsequent ARM series in 4.8 -- it is
>>> still possible we get an ack from Lenovo any time, but the issue is out
>>> of our control at the moment. It's just one unfortunate incident in
>>> open
>>> source software development. Sigh.
>>
>> One option could be to provide a 'gpl_all' (or some such) target in
>> libacpi in addition to 'all' and that target will be careful about not
>> including these small un-ACKed portions of the code.
>>
>> It will be ugly though.
>
> I agree that it is not nice, but it would help us to get this features
> (and the other ones that depend on it) in Xen 4.8. Otherwise we would
> have to wait another 6 months to get those features.


If Jan (who is/will be libacpi maintainer) agrees to this it can be
easily added.

-boris


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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 14:07             ` Boris Ostrovsky
@ 2016-09-15 14:21               ` Jan Beulich
  2016-09-15 15:28                 ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-15 14:21 UTC (permalink / raw)
  To: Julien Grall, Wei Liu, Boris Ostrovsky
  Cc: Stefano Stabellini, andrew.cooper3, xen.org, xen-devel,
	zhaoshenglong, roger.pau

>>> On 15.09.16 at 16:07, <boris.ostrovsky@oracle.com> wrote:
> On 09/15/2016 09:48 AM, Julien Grall wrote:
>> On 15/09/2016 13:39, Boris Ostrovsky wrote:
>>> One option could be to provide a 'gpl_all' (or some such) target in
>>> libacpi in addition to 'all' and that target will be careful about not
>>> including these small un-ACKed portions of the code.
>>>
>>> It will be ugly though.
>>
>> I agree that it is not nice, but it would help us to get this features
>> (and the other ones that depend on it) in Xen 4.8. Otherwise we would
>> have to wait another 6 months to get those features.
> 
> 
> If Jan (who is/will be libacpi maintainer) agrees to this it can be
> easily added.

I'd like to make this dependent on how ugly it ends up being.

Jan


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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 14:21               ` Jan Beulich
@ 2016-09-15 15:28                 ` Boris Ostrovsky
  2016-09-15 16:05                   ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-15 15:28 UTC (permalink / raw)
  To: Jan Beulich, Julien Grall, Wei Liu
  Cc: Stefano Stabellini, andrew.cooper3, xen.org, xen-devel,
	zhaoshenglong, roger.pau

[-- Attachment #1: Type: text/plain, Size: 5342 bytes --]

On 09/15/2016 10:21 AM, Jan Beulich wrote:
>>>> On 15.09.16 at 16:07, <boris.ostrovsky@oracle.com> wrote:
>> On 09/15/2016 09:48 AM, Julien Grall wrote:
>>> On 15/09/2016 13:39, Boris Ostrovsky wrote:
>>>> One option could be to provide a 'gpl_all' (or some such) target in
>>>> libacpi in addition to 'all' and that target will be careful about not
>>>> including these small un-ACKed portions of the code.
>>>>
>>>> It will be ugly though.
>>>
>>> I agree that it is not nice, but it would help us to get this features
>>> (and the other ones that depend on it) in Xen 4.8. Otherwise we would
>>> have to wait another 6 months to get those features.
>>
>>
>> If Jan (who is/will be libacpi maintainer) agrees to this it can be
>> easily added.
> 
> I'd like to make this dependent on how ugly it ends up being.
> 
> Jan
> 

Something along the lines of this (attached as well to prevent line
wrapping)

Maybe even without changes to mk_dsdt.c

-boris


>From 15149f5d6ac15d7e7da650259dfcfaf4097b03ae Mon Sep 17 00:00:00 2001
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Date: Thu, 15 Sep 2016 11:15:31 -0400
Subject: [PATCH] libacpi: Prevent GPL-only code from seeping into non-GPL
 binaries

Some code (specifically, introduced by commit 801d469ad ("[HVM] ACPI
support patch 3 of 4: ACPI _PRT table.")) has only been licensed by
GPLv2.1

We want to prevent this code from showing up in non-GPL binaries.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 tools/firmware/hvmloader/Makefile |  4 ++--
 tools/libacpi/Makefile            |  9 ++++++---
 tools/libacpi/mk_dsdt.c           | 10 ++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/firmware/hvmloader/Makefile
b/tools/firmware/hvmloader/Makefile
index 9fa9bcc..dc21cdf 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -69,7 +69,7 @@ all: acpi subdirs-all

 .PHONY: acpi
 acpi:
-	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR)
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) GPL=true

 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
@@ -119,7 +119,7 @@ endif
 clean: subdirs-clean
 	rm -f roms.inc roms.inc.new acpi.h
 	rm -f hvmloader hvmloader.tmp *.o $(DEPS)
-	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) clean
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) GPL=true clean

 .PHONY: distclean
 distclean: clean
diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 2d8a954..2fe14d4 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -18,7 +18,10 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt

 # Sources to be generated
-C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c
dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
+C_SRC = $(ACPI_BUILD_DIR)/dsdt_pvh.c
+ifeq ($(GPL),true)
+C_SRC += $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c
dsdt_anycpu_qemu_xen.c)
+endif
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h
ssdt_tpm.h)

 ifeq ($(subst all,,$(MAKECMDGOALS)),)
@@ -39,14 +42,14 @@ $(MK_DSDT): mk_dsdt.c
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl
$(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $(TDIR)/$(@F)
 	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
-	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen --gpl >> $(TDIR)/$(@F)
 	cp $(TDIR)/$(@F) $@

 # NB. awk invocation is a portable alternative to 'head -n -1'
 $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $(TDIR)/$(@F)
 	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
-	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --maxcpu $* --gpl >> $(TDIR)/$(@F)
 	cp $(TDIR)/$(@F) $@

 $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index 30477fd..c79e95f 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -99,6 +99,7 @@ static struct option options[] = {
     { "maxcpu", 1, 0, 'c' },
     { "dm-version", 1, 0, 'q' },
     { "debug", 1, 0, 'd' },
+    { "gpl", 0,0,'g' },
     { 0, 0, 0, 0 }
 };

@@ -106,6 +107,7 @@ int main(int argc, char **argv)
 {
     unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
+    bool gpl = false;

     for ( ; ; )
     {
@@ -147,6 +149,9 @@ int main(int argc, char **argv)
             if (*optarg == 'y')
                 debug = true;
             break;
+        case 'g':
+            gpl = true;
+            break;
         default:
             return -1;
         }
@@ -293,6 +298,9 @@ int main(int argc, char **argv)
         }
     } pop_block();

+    if (!gpl)
+        goto cont; // Should be "if (gpl) {...}", 'goto' is for
pre-review, small diff
+
     /*** PCI-ISA link definitions ***/
     /* BUFA: List of ISA IRQs available for linking to PCI INTx. */
     stmt("Name", "BUFA, ResourceTemplate() { "
@@ -359,6 +367,8 @@ int main(int argc, char **argv)
                    dev, intx, ((dev*4+dev/8+intx)&31)+16);
     printf("})\n");

+cont:
+
     /*
      * Each PCI hotplug slot needs at least two methods to handle
      * the ACPI event:
-- 
1.8.3.1



[-- Attachment #2: 0001-libacpi-Prevent-GPL-only-code-from-seeping-into-non-.patch --]
[-- Type: text/x-patch, Size: 4399 bytes --]

>From 15149f5d6ac15d7e7da650259dfcfaf4097b03ae Mon Sep 17 00:00:00 2001
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Date: Thu, 15 Sep 2016 11:15:31 -0400
Subject: [PATCH] libacpi: Prevent GPL-only code from seeping into non-GPL
 binaries

Some code (specifically, introduced by commit 801d469ad ("[HVM] ACPI
support patch 3 of 4: ACPI _PRT table.")) has only been licensed by
GPLv2.1

We want to prevent this code from showing up in non-GPL binaries.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 tools/firmware/hvmloader/Makefile |  4 ++--
 tools/libacpi/Makefile            |  9 ++++++---
 tools/libacpi/mk_dsdt.c           | 10 ++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 9fa9bcc..dc21cdf 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -69,7 +69,7 @@ all: acpi subdirs-all
 
 .PHONY: acpi
 acpi:
-	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR)
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) GPL=true
 
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
@@ -119,7 +119,7 @@ endif
 clean: subdirs-clean
 	rm -f roms.inc roms.inc.new acpi.h
 	rm -f hvmloader hvmloader.tmp *.o $(DEPS)
-	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) clean
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) GPL=true clean
 
 .PHONY: distclean
 distclean: clean
diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 2d8a954..2fe14d4 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -18,7 +18,10 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
 # Sources to be generated
-C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c dsdt_pvh.c)
+C_SRC = $(ACPI_BUILD_DIR)/dsdt_pvh.c
+ifeq ($(GPL),true)
+C_SRC += $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c  dsdt_anycpu_qemu_xen.c)
+endif
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 ifeq ($(subst all,,$(MAKECMDGOALS)),)
@@ -39,14 +42,14 @@ $(MK_DSDT): mk_dsdt.c
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $(TDIR)/$(@F)
 	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
-	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen --gpl >> $(TDIR)/$(@F)
 	cp $(TDIR)/$(@F) $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
 $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $(TDIR)/$(@F)
 	cat dsdt_acpi_info.asl >> $(TDIR)/$(@F)
-	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $(TDIR)/$(@F)
+	$(MK_DSDT) --debug=$(debug) --maxcpu $* --gpl >> $(TDIR)/$(@F)
 	cp $(TDIR)/$(@F) $@
 
 $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT)
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index 30477fd..c79e95f 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -99,6 +99,7 @@ static struct option options[] = {
     { "maxcpu", 1, 0, 'c' },
     { "dm-version", 1, 0, 'q' },
     { "debug", 1, 0, 'd' },
+    { "gpl", 0,0,'g' },
     { 0, 0, 0, 0 }
 };
 
@@ -106,6 +107,7 @@ int main(int argc, char **argv)
 {
     unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
+    bool gpl = false;
 
     for ( ; ; )
     {
@@ -147,6 +149,9 @@ int main(int argc, char **argv)
             if (*optarg == 'y')
                 debug = true;
             break;
+        case 'g':
+            gpl = true;
+            break;
         default:
             return -1;
         }
@@ -293,6 +298,9 @@ int main(int argc, char **argv)
         }
     } pop_block();
 
+    if (!gpl)
+        goto cont; // Should be "if (gpl) {...}", 'goto' is for pre-review, small diff
+
     /*** PCI-ISA link definitions ***/
     /* BUFA: List of ISA IRQs available for linking to PCI INTx. */
     stmt("Name", "BUFA, ResourceTemplate() { "
@@ -359,6 +367,8 @@ int main(int argc, char **argv)
                    dev, intx, ((dev*4+dev/8+intx)&31)+16);
     printf("})\n");
 
+cont:
+
     /*
      * Each PCI hotplug slot needs at least two methods to handle
      * the ACPI event:
-- 
1.8.3.1


[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 15:28                 ` Boris Ostrovsky
@ 2016-09-15 16:05                   ` Jan Beulich
  2016-09-15 16:40                     ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-15 16:05 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Stefano Stabellini, Wei Liu, andrew.cooper3, xen.org, xen-devel,
	Julien Grall, zhaoshenglong, roger.pau

>>> On 15.09.16 at 17:28, <boris.ostrovsky@oracle.com> wrote:
> Something along the lines of this (attached as well to prevent line
> wrapping)

Looks reasonable with some polishing (GPL=y on the make lines and
using C_SRC-$(GPL) and CSRC-y).

> Maybe even without changes to mk_dsdt.c

But isn't that the critical part? And - what functionality do we lose
without that code? There's no point in generating something that's
of no practical use.

And then there's the question of whether excluding things from the
build, but having them present in the sources actually helps.

Jan


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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 16:05                   ` Jan Beulich
@ 2016-09-15 16:40                     ` Boris Ostrovsky
  2016-09-16  6:45                       ` Jan Beulich
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-15 16:40 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, andrew.cooper3, xen.org, xen-devel,
	Julien Grall, zhaoshenglong, roger.pau

On 09/15/2016 12:05 PM, Jan Beulich wrote

>> Maybe even without changes to mk_dsdt.c
> But isn't that the critical part? 

Not necessarily since we'd use --gpl option only for
dsdt_anycpu_qemu_xen, dsdt_anycpu and dsdt_15cpu and these files are not
used by the non-GPL caller, which is libxl (it only wants dsdt_pvh).

Of course, this is what we have currently.

> And - what functionality do we lose
> without that code? There's no point in generating something that's
> of no practical use.

We don't lose any functionality (again, currently). In fact, this
indirectly prevents us from generating unnecessary files listed above.

> And then there's the question of whether excluding things from the
> build, but having them present in the sources actually helps.

The main reason for this whole relicensing debacle is to prevent non-GPL
binaries from linking against GPL objects, and this patch allows us to
do that. Yes, there will be be two non-LGPL files (dsdt.asl amd
mk_dsdt.c, which I will revert back to GPL) in an otherwise LGPL
directory but that's an in-convenience and not a license violation.



-boris




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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-15 16:40                     ` Boris Ostrovsky
@ 2016-09-16  6:45                       ` Jan Beulich
  2016-09-16 12:41                         ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Jan Beulich @ 2016-09-16  6:45 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Stefano Stabellini, Wei Liu, andrew.cooper3, xen.org, xen-devel,
	Julien Grall, zhaoshenglong, roger.pau

>>> On 15.09.16 at 18:40, <boris.ostrovsky@oracle.com> wrote:
> On 09/15/2016 12:05 PM, Jan Beulich wrote
> 
>>> Maybe even without changes to mk_dsdt.c
>> But isn't that the critical part? 
> 
> Not necessarily since we'd use --gpl option only for
> dsdt_anycpu_qemu_xen, dsdt_anycpu and dsdt_15cpu and these files are not
> used by the non-GPL caller, which is libxl (it only wants dsdt_pvh).
> 
> Of course, this is what we have currently.

Right - and with the goal to guard against future changes I think
we'd better not omit those parts.

>> And - what functionality do we lose
>> without that code? There's no point in generating something that's
>> of no practical use.
> 
> We don't lose any functionality (again, currently). In fact, this
> indirectly prevents us from generating unnecessary files listed above.

Agreed - I got the sense of the check in mk_dsdt.c the wrong way
round.

>> And then there's the question of whether excluding things from the
>> build, but having them present in the sources actually helps.
> 
> The main reason for this whole relicensing debacle is to prevent non-GPL
> binaries from linking against GPL objects, and this patch allows us to
> do that. Yes, there will be be two non-LGPL files (dsdt.asl amd
> mk_dsdt.c, which I will revert back to GPL) in an otherwise LGPL
> directory but that's an in-convenience and not a license violation.

Well, if linking is all this is about, then it's fine of course. I'm just
not a license expert, so we'd need this acked by someone who is
more familiar with the differences and implications.

Jan


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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-16  6:45                       ` Jan Beulich
@ 2016-09-16 12:41                         ` Boris Ostrovsky
  2016-09-16 15:22                           ` Lars Kurth
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-16 12:41 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Lars Kurth, Stefano Stabellini, Wei Liu, andrew.cooper3,
	Ian Jackson, xen-devel, Julien Grall, zhaoshenglong, roger.pau

On 09/16/2016 02:45 AM, Jan Beulich wrote:
>
>>> And then there's the question of whether excluding things from the
>>> build, but having them present in the sources actually helps.
>> The main reason for this whole relicensing debacle is to prevent non-GPL
>> binaries from linking against GPL objects, and this patch allows us to
>> do that. Yes, there will be be two non-LGPL files (dsdt.asl amd
>> mk_dsdt.c, which I will revert back to GPL) in an otherwise LGPL
>> directory but that's an in-convenience and not a license violation.
> Well, if linking is all this is about, then it's fine of course. I'm just
> not a license expert, so we'd need this acked by someone who is
> more familiar with the differences and implications.


I think Ian and Lars (added both here) would be the most experienced in
this matter.

I could move these two files into tools/libacpi/gpl subdirectory to
emphasize their special licensing.

-boris


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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-16 12:41                         ` Boris Ostrovsky
@ 2016-09-16 15:22                           ` Lars Kurth
  2016-09-16 15:53                             ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Lars Kurth @ 2016-09-16 15:22 UTC (permalink / raw)
  To: Boris Ostrovsky, Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, xen-devel,
	Julien Grall, zhaoshenglong, Ian Jackson, Roger Pau Monne



On 16/09/2016 13:41, "Boris Ostrovsky" <boris.ostrovsky@oracle.com> wrote:

>On 09/16/2016 02:45 AM, Jan Beulich wrote:
>>
>>>> And then there's the question of whether excluding things from the
>>>> build, but having them present in the sources actually helps.
>>> The main reason for this whole relicensing debacle is to prevent
>>>non-GPL
>>> binaries from linking against GPL objects, and this patch allows us to
>>> do that. Yes, there will be be two non-LGPL files (dsdt.asl amd
>>> mk_dsdt.c, which I will revert back to GPL) in an otherwise LGPL
>>> directory but that's an in-convenience and not a license violation.
>> Well, if linking is all this is about, then it's fine of course. I'm
>>just
>> not a license expert, so we'd need this acked by someone who is
>> more familiar with the differences and implications.
>
>I think Ian and Lars (added both here) would be the most experienced in
>this matter.

It is all about linking. The terms of the GPL "spread" to derivative works
through both “dynamic” and “static” linking of binaries only. So you can
have one directory, which contains GPL and non-GPL licensed files, and not
suffer GPL-contagion as long as you can guarantee that the binaries
produced are of a specific license and you only link compatible binaries
with each other. Of course that is brittle and error prone.

> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
> (which is the patch from Lenovo) and it only does 2 things (assuming I
> parsed ASL correctly):
> * Adds _PIC method
As far as I can tell, only lines 30-43 of the original code remains.
Is this correct?

> * Controls and describes legacy PCI interrupt routing. This
> functionality has actually been moved into mk_dsdt.c and so this ASL
> code is now generated.


Has it been 
a) moved, 
b) re-implemented in a different language using the ASL code as template,
or 
c) implemented in C based on the ACPI spec?

Given that mk_dsdt.c is C and the original contribution is entirely ASL
(note that acpi_dsdt.c was generated from the ASL), a) does not appear to
be the case.

b) can probably not be excluded, in which case it may be safer to keep
mk_dsdt.c as GPL. But it would be a grey area.

If we knew for sure or it is plausible enough that it was c), then
mk_dsdt.c does not need to be GPL. And then the remaining Lenovo code in
dsdt.asl may be simple enough to not be copyrightable.

Whatever the answer, I would like to get Ian's opinion.
And it is still preferable though to have the entire component in LGPL and
to get a Lenovo ACK.

>I could move these two files into tools/libacpi/gpl subdirectory to
>emphasize their special licensing.

That would definitely make things easier and avoid any future mistakes
which lead to licensing issues.

Another general comment is that the component should have a COPYING file
and maybe a README.source file in the new component (that will make future
forensics easier). 

Regards
Lars

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-16 15:22                           ` Lars Kurth
@ 2016-09-16 15:53                             ` Boris Ostrovsky
  2016-09-19 15:30                               ` Ian Jackson
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-16 15:53 UTC (permalink / raw)
  To: Lars Kurth, Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, xen-devel,
	Julien Grall, zhaoshenglong, Ian Jackson, Roger Pau Monne

On 09/16/2016 11:22 AM, Lars Kurth wrote:
>
> On 16/09/2016 13:41, "Boris Ostrovsky" <boris.ostrovsky@oracle.com> wrote:
>
>> On 09/16/2016 02:45 AM, Jan Beulich wrote:
>>>>> And then there's the question of whether excluding things from the
>>>>> build, but having them present in the sources actually helps.
>>>> The main reason for this whole relicensing debacle is to prevent
>>>> non-GPL
>>>> binaries from linking against GPL objects, and this patch allows us to
>>>> do that. Yes, there will be be two non-LGPL files (dsdt.asl amd
>>>> mk_dsdt.c, which I will revert back to GPL) in an otherwise LGPL
>>>> directory but that's an in-convenience and not a license violation.
>>> Well, if linking is all this is about, then it's fine of course. I'm
>>> just
>>> not a license expert, so we'd need this acked by someone who is
>>> more familiar with the differences and implications.
>> I think Ian and Lars (added both here) would be the most experienced in
>> this matter.
> It is all about linking. The terms of the GPL "spread" to derivative works
> through both “dynamic” and “static” linking of binaries only. So you can
> have one directory, which contains GPL and non-GPL licensed files, and not
> suffer GPL-contagion as long as you can guarantee that the binaries
> produced are of a specific license and you only link compatible binaries
> with each other. Of course that is brittle and error prone.
>
>> So I looked again at commit 801d469ad8b2b88f669326327df03d03200efbfb
>> (which is the patch from Lenovo) and it only does 2 things (assuming I
>> parsed ASL correctly):
>> * Adds _PIC method
> As far as I can tell, only lines 30-43 of the original code remains.
> Is this correct?

_S5 object still exists but it's content has been modified by subsequent
non-Lenovo changes so I think we can not worry about lines 20-30.

But lines 30-43 are still present in current code.

>
>> * Controls and describes legacy PCI interrupt routing. This
>> functionality has actually been moved into mk_dsdt.c and so this ASL
>> code is now generated.
>
> Has it been 
> a) moved, 
> b) re-implemented in a different language using the ASL code as template,

(b) is probably the best description.


> or 
> c) implemented in C based on the ACPI spec?
>
> Given that mk_dsdt.c is C and the original contribution is entirely ASL
> (note that acpi_dsdt.c was generated from the ASL), a) does not appear to
> be the case.
>
> b) can probably not be excluded, in which case it may be safer to keep
> mk_dsdt.c as GPL. But it would be a grey area.
>
> If we knew for sure or it is plausible enough that it was c), then
> mk_dsdt.c does not need to be GPL. 

Both hand-crafted and mk_dsdt-generated ASL file are *conforming* to
ACPI spec but the values (i.e. the topology that the ASL file describes)
are specifically chosen so I don't think (c) is the right answer.

Having said that it is entirely plausible that the author of the patch
ran iasl on his machine and took the output from it to produce the
patch, possibly with minor tweaks. But we, of course, don't know for sure.

> And then the remaining Lenovo code in
> dsdt.asl may be simple enough to not be copyrightable.
>
> Whatever the answer, I would like to get Ian's opinion.
> And it is still preferable though to have the entire component in LGPL and
> to get a Lenovo ACK.
>
>> I could move these two files into tools/libacpi/gpl subdirectory to
>> emphasize their special licensing.
> That would definitely make things easier and avoid any future mistakes
> which lead to licensing issues.
>
> Another general comment is that the component should have a COPYING file
> and maybe a README.source file in the new component (that will make future
> forensics easier). 

I'll add a COPYING file (we already have a README).


-boris



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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-16 15:53                             ` Boris Ostrovsky
@ 2016-09-19 15:30                               ` Ian Jackson
  2016-09-19 15:42                                 ` Boris Ostrovsky
  0 siblings, 1 reply; 71+ messages in thread
From: Ian Jackson @ 2016-09-19 15:30 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Lars Kurth, Stefano Stabellini, Wei Liu, Andrew Cooper,
	xen-devel, Julien Grall, Jan Beulich, zhaoshenglong,
	Roger Pau Monne

Boris Ostrovsky writes ("Re: [Xen-devel] [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader"):
> _S5 object still exists but it's content has been modified by subsequent
> non-Lenovo changes so I think we can not worry about lines 20-30.
> 
> But lines 30-43 are still present in current code.

Are we really having this much trouble over 13 lines ?  Do we have
someone (who hasn't read the existing code) who could write 13 lines
of DSDT ?

Ian.

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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-19 15:30                               ` Ian Jackson
@ 2016-09-19 15:42                                 ` Boris Ostrovsky
  2016-09-19 15:49                                   ` Ian Jackson
  0 siblings, 1 reply; 71+ messages in thread
From: Boris Ostrovsky @ 2016-09-19 15:42 UTC (permalink / raw)
  To: Ian Jackson
  Cc: Lars Kurth, Stefano Stabellini, Wei Liu, Andrew Cooper,
	xen-devel, Julien Grall, Jan Beulich, zhaoshenglong,
	Roger Pau Monne

On 09/19/2016 11:30 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("Re: [Xen-devel] [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader"):
>> _S5 object still exists but it's content has been modified by subsequent
>> non-Lenovo changes so I think we can not worry about lines 20-30.
>>
>> But lines 30-43 are still present in current code.
> Are we really having this much trouble over 13 lines ?  Do we have
> someone (who hasn't read the existing code) who could write 13 lines
> of DSDT ?

This is a bug fix (it implements section 5.8.1 of the spec, to be exact)
and presumably anyone with basic ASL knowledge would have been able to
write it.

But we'd still have to deal with mk_dsdt.c which is where the second,
larger, chunk of Lenovo patch went.

-boris


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

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

* Re: [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader
  2016-09-19 15:42                                 ` Boris Ostrovsky
@ 2016-09-19 15:49                                   ` Ian Jackson
  0 siblings, 0 replies; 71+ messages in thread
From: Ian Jackson @ 2016-09-19 15:49 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Lars Kurth, Stefano Stabellini, Wei Liu, Andrew Cooper,
	xen-devel, Julien Grall, Jan Beulich, zhaoshenglong,
	Roger Pau Monne

Boris Ostrovsky writes ("Re: [Xen-devel] [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader"):
> But we'd still have to deal with mk_dsdt.c which is where the second,
> larger, chunk of Lenovo patch went.

Right, sorry, I had misunderstood.

Ian.

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

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

end of thread, other threads:[~2016-09-19 15:49 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07 18:59 [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
2016-09-07 19:48   ` Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader Boris Ostrovsky
2016-09-08 13:41   ` Jan Beulich
2016-09-07 18:59 ` [PATCH v3 03/19] acpi/hvmloader: Set TIS header address " Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 04/19] acpi/hvmloader: Make providing IOAPIC in MADT optional Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 05/19] acpi/hvmloader: Build WAET optionally Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops Boris Ostrovsky
2016-09-08 13:54   ` Jan Beulich
2016-09-07 18:59 ` [PATCH v3 07/19] acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly Boris Ostrovsky
2016-09-08 13:56   ` Jan Beulich
2016-09-07 18:59 ` [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments Boris Ostrovsky
2016-09-08 14:05   ` Jan Beulich
2016-09-08 18:29     ` Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 10/19] acpi: Move ACPI code to tools/libacpi Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 11/19] x86: Allow LAPIC-only emulation_flags for HVM guests Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 12/19] libacpi: Build DSDT for PVH guests Boris Ostrovsky
2016-09-08 14:09   ` Jan Beulich
2016-09-14  4:13   ` Shannon Zhao
2016-09-14 12:47     ` Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts Boris Ostrovsky
2016-09-08 14:15   ` Jan Beulich
2016-09-08 18:51     ` Boris Ostrovsky
2016-09-09  8:03       ` Jan Beulich
2016-09-09 13:07         ` Boris Ostrovsky
2016-09-09 13:29           ` Jan Beulich
2016-09-09 13:56             ` Boris Ostrovsky
2016-09-09 14:13               ` Ian Jackson
2016-09-09 14:31                 ` Boris Ostrovsky
2016-09-09 14:33                   ` Ian Jackson
2016-09-09 14:38                     ` Boris Ostrovsky
2016-09-09 15:20               ` Jan Beulich
2016-09-09 16:05                 ` Boris Ostrovsky
2016-09-09 16:11                   ` Jan Beulich
2016-09-07 18:59 ` [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules Boris Ostrovsky
2016-09-15 10:13   ` Wei Liu
2016-09-07 18:59 ` [PATCH v3 15/19] libxl/acpi: Add ACPI e820 entry Boris Ostrovsky
2016-09-15 10:13   ` Wei Liu
2016-09-07 18:59 ` [PATCH v3 16/19] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests Boris Ostrovsky
2016-09-15 10:13   ` Wei Liu
2016-09-07 18:59 ` [PATCH v3 17/19] ilibxl: Initialize domain build info before calling libxl__domain_make Boris Ostrovsky
2016-09-15 10:13   ` Wei Liu
2016-09-07 18:59 ` [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests Boris Ostrovsky
2016-09-08 14:20   ` Jan Beulich
2016-09-08 18:53     ` Boris Ostrovsky
2016-09-09  8:05       ` Jan Beulich
2016-09-09 13:11         ` Boris Ostrovsky
2016-09-09 13:50           ` Ian Jackson
2016-09-09 14:02             ` Boris Ostrovsky
2016-09-07 18:59 ` [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space Boris Ostrovsky
2016-09-15 10:13   ` Wei Liu
2016-09-14 15:21 ` [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
2016-09-15 10:18   ` Wei Liu
2016-09-15 10:20     ` Julien Grall
2016-09-15 10:22       ` Wei Liu
2016-09-15 12:39         ` Boris Ostrovsky
2016-09-15 13:48           ` Julien Grall
2016-09-15 14:07             ` Boris Ostrovsky
2016-09-15 14:21               ` Jan Beulich
2016-09-15 15:28                 ` Boris Ostrovsky
2016-09-15 16:05                   ` Jan Beulich
2016-09-15 16:40                     ` Boris Ostrovsky
2016-09-16  6:45                       ` Jan Beulich
2016-09-16 12:41                         ` Boris Ostrovsky
2016-09-16 15:22                           ` Lars Kurth
2016-09-16 15:53                             ` Boris Ostrovsky
2016-09-19 15:30                               ` Ian Jackson
2016-09-19 15:42                                 ` Boris Ostrovsky
2016-09-19 15:49                                   ` Ian Jackson

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.