Skip to contentSkip to conversation

Make ACPI builder available to components other than hvmloader

PATCH Superseded Boris Ostrovsky 7 participants 71 messages Sep 7, 2016 – Sep 19, 2016

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Make ACPI builder available to components other than hvmloader

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
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v3 1/19 acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1

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

---
CC: Daniel Kiper <[email protected]>
CC: Stefan Berger <[email protected]>
CC: Kouya Shimura <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Keir Fraser <[email protected]>
CC: Simon Horman <[email protected]>
CC: Lars Kurth <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
---

* 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(-)
tools/firmware/hvmloader/acpi/Makefile +8 -10
index d3e882a..703d67b 100644
@@ -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)/../../../..
tools/firmware/hvmloader/acpi/acpi2_0.h +8 -11
index 87a558a..775eb7a 100644
@@ -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_
tools/firmware/hvmloader/acpi/build.c +8 -10
index dccddff..de56f1f 100644
@@ -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"
tools/firmware/hvmloader/acpi/dsdt.asl +8 -10
index bd65823..895a8e5 100644
@@ -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)
tools/firmware/hvmloader/acpi/mk_dsdt.c +12 -0
index b2ade89..bc414bf 100644
@@ -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>
tools/firmware/hvmloader/acpi/ssdt_pm.asl +4 -7
index 1a7d752..d81b1f2 100644
@@ -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.
  */
 
 /*
tools/firmware/hvmloader/acpi/ssdt_s3.asl +4 -7
index f89ac02..c83bbbf 100644
@@ -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)
tools/firmware/hvmloader/acpi/ssdt_s4.asl +4 -7
index d589e4b..325ac11 100644
@@ -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)
tools/firmware/hvmloader/acpi/ssdt_tpm.asl +8 -10
index 2ae8ad4..a0fb1fd 100644
@@ -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. */
tools/firmware/hvmloader/acpi/static_tables.c +8 -10
index f4d627b..617bf68 100644
@@ -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"
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH v3 01/19] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1

Adding Lenovo.

Quoted 318 lines · Boris Ostrovsky

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

---
CC: Daniel Kiper <[email protected]>
CC: Stefan Berger <[email protected]>
CC: Kouya Shimura <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Keir Fraser <[email protected]>
CC: Simon Horman <[email protected]>
CC: Lars Kurth <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
---

* 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(-)
tools/firmware/hvmloader/acpi/Makefile +8 -10
index d3e882a..703d67b 100644
@@ -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)/../../../..
tools/firmware/hvmloader/acpi/acpi2_0.h +8 -11
index 87a558a..775eb7a 100644
@@ -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_
tools/firmware/hvmloader/acpi/build.c +8 -10
index dccddff..de56f1f 100644
@@ -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"
tools/firmware/hvmloader/acpi/dsdt.asl +8 -10
index bd65823..895a8e5 100644
@@ -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)
tools/firmware/hvmloader/acpi/mk_dsdt.c +12 -0
index b2ade89..bc414bf 100644
@@ -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>
tools/firmware/hvmloader/acpi/ssdt_pm.asl +4 -7
index 1a7d752..d81b1f2 100644
@@ -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.
  */
 
 /*
tools/firmware/hvmloader/acpi/ssdt_s3.asl +4 -7
index f89ac02..c83bbbf 100644
@@ -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)
tools/firmware/hvmloader/acpi/ssdt_s4.asl +4 -7
index d589e4b..325ac11 100644
@@ -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)
tools/firmware/hvmloader/acpi/ssdt_tpm.asl +8 -10
index 2ae8ad4..a0fb1fd 100644
@@ -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. */
tools/firmware/hvmloader/acpi/static_tables.c +4 -7
index f4d627b..617bf68 100644
@@ -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.

tools/firmware/hvmloader/acpi/static_tables.c line 16

Quoted 10 lines
tools/firmware/hvmloader/acpi/static_tables.c +4 -3
- *
- * 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
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

PATCH v3 2/19 acpi/hvmloader: Collect processor and NUMA info in hvmloader

In reply to Boris Ostrovsky

No need for ACPI code to rely on hvm_info variable.

---
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(-)
tools/firmware/hvmloader/acpi/build.c +27 -24
index de56f1f..5f5c5f0 100644
@@ -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;
tools/firmware/hvmloader/acpi/libacpi.h +13 -0
index 22fd5f6..78c3a1c 100644
@@ -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, ....)
tools/firmware/hvmloader/util.c +9 -0
index b2d3421..f37b16e 100644
@@ -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;
 
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

Re: [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

Changes in v3:
* Constified acpi_numa's pointers
* Constified acpi_config call parameter where possible

Thanks, but how about ...

Quoted 5 lines
tools/firmware/hvmloader/acpi/build.c +0 -0
@@ -70,18 +70,20 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }

tools/firmware/hvmloader/acpi/build.c static void set_checksum( · line 80

Quoted 10 lines
tools/firmware/hvmloader/acpi/build.c +3 -1
 
-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?

tools/firmware/hvmloader/acpi/libacpi.h line 23

Quoted 7 lines
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
@@ -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.

tools/firmware/hvmloader/acpi/libacpi.h struct acpi_config { · line 63

Quoted 6 lines
tools/firmware/hvmloader/acpi/libacpi.h +2 -0
@@ -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
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

PATCH v3 3/19 acpi/hvmloader: Set TIS header address in hvmloader

In reply to Boris Ostrovsky

Users other than hvmloader may provide TIS address as virtual.

---
 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(-)
tools/firmware/hvmloader/acpi/build.c +4 -5
index 5f5c5f0..80386b9 100644
@@ -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;
tools/firmware/hvmloader/acpi/libacpi.h +3 -0
index 78c3a1c..cc57a9c 100644
@@ -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, ....)
tools/firmware/hvmloader/config.h +2 -0
index a4429f4..6e00413 100644
@@ -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;
 
tools/firmware/hvmloader/util.c +4 -0
index f37b16e..8875675 100644
@@ -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;
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

PATCH v3 4/19 acpi/hvmloader: Make providing IOAPIC in MADT optional

In reply to Boris Ostrovsky
---
 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(-)
tools/firmware/hvmloader/acpi/build.c +38 -32
index 80386b9..7e7c11f 100644
@@ -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++ )
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
index cc57a9c..b089cc5 100644
@@ -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 {
tools/firmware/hvmloader/util.c +1 -1
index 8875675..aa5fc20 100644
@@ -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;
 
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

PATCH v3 5/19 acpi/hvmloader: Build WAET optionally

In reply to Boris Ostrovsky

---
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(-)
tools/firmware/hvmloader/acpi/build.c +7 -3
index 7e7c11f..1ea146f 100644
@@ -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 )
     {
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
index b089cc5..7a18d05 100644
@@ -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 {
tools/firmware/hvmloader/util.c +1 -1
index aa5fc20..b345576 100644
@@ -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;
 
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#8 lore raw

PATCH v3 6/19 acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops

In reply to Boris Ostrovsky

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.

---
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(-)
tools/firmware/hvmloader/acpi/build.c +52 -43
index 1ea146f..9c4a0a0 100644
@@ -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;
tools/firmware/hvmloader/acpi/libacpi.h +9 -1
index 7a18d05..3bcd226 100644
@@ -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__ */
 
tools/firmware/hvmloader/util.c +22 -1
index b345576..8773e69 100644
@@ -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);
 }
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v3 6/19
#9 lore raw

Re: [PATCH v3 06/19] acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> 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.

Albeit I'd prefer if ...

Quoted 11 lines
tools/firmware/hvmloader/util.c +5 -0
@@ -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);
+}
+

tools/firmware/hvmloader/util.c static uint8_t battery_port_exists(void) · line 883

Quoted 10 lines
tools/firmware/hvmloader/util.c +10 -0
+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
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw

PATCH v3 7/19 acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables

In reply to Boris Ostrovsky

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.

---
 tools/firmware/hvmloader/acpi/build.c | 47 ++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 23 deletions(-)
tools/firmware/hvmloader/acpi/build.c +24 -23
index 9c4a0a0..2098920 100644
@@ -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));
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#11 lore raw

PATCH v3 8/19 acpi/hvmloader: Link ACPI object files directly

In reply to Boris Ostrovsky

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.

---
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(-)
.gitignore +4 -4
index 43c6f93..9b2c405 100644
@@ -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
tools/firmware/hvmloader/Makefile +10 -1
index 9f7357f..b6c5b83 100644
@@ -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
tools/firmware/hvmloader/acpi/Makefile +19 -24

69 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v3 8/19
#12 lore raw

Re: [PATCH v3 08/19] acpi/hvmloader: Link ACPI object files directly

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> 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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

PATCH v3 9/19 acpi/hvmloader: Include file/paths adjustments

In reply to Boris Ostrovsky

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

---
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(-)
tools/firmware/hvmloader/Makefile +2 -1
index b6c5b83..77e95f1 100644
@@ -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)
tools/firmware/hvmloader/acpi/README +12 -4
index 210d5ba..2b9d6e1 100644
@@ -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
 ------------------
tools/firmware/hvmloader/acpi/build.c +10 -9
index 2098920..1cd640d 100644
@@ -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++;
     }
tools/firmware/hvmloader/acpi/libacpi.h +7 -0
index 3bcd226..d803139 100644
@@ -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);
tools/firmware/hvmloader/hvmloader.c +1 -1
index bbd4e34..77b9536 100644
@@ -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>
tools/firmware/hvmloader/rombios.c +1 -1
index 9acf03f..56b39b7 100644
@@ -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
tools/firmware/hvmloader/seabios.c +3 -2
index 44ff0d7..870576a 100644
@@ -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;
tools/firmware/hvmloader/util.c +13 -2
index 8773e69..6d636bf 100644
@@ -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) )
tools/firmware/rombios/32bit/Makefile +1 -1
index 396906c..71399d2 100644
@@ -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
 
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
index f6f2649..6822027 100644
@@ -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)
tools/firmware/rombios/32bit/util.h +1 -1
index e245be6..6b90c43 100644
@@ -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);
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#14 lore raw

Re: [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments

Quoted 168 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> 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

---
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(-)
tools/firmware/hvmloader/Makefile +2 -2
index b6c5b83..77e95f1 100644
@@ -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)
tools/firmware/hvmloader/acpi/README +3 -4
index 210d5ba..2b9d6e1 100644
@@ -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

tools/firmware/hvmloader/acpi/README +8 -0
+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

tools/firmware/hvmloader/acpi/README +1 -0
+for an example.
 
 Note on DSDT Table
 ------------------
tools/firmware/hvmloader/acpi/build.c +4 -3
index 2098920..1cd640d 100644
@@ -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);
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -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 )
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -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;
tools/firmware/hvmloader/acpi/build.c +2 -2
@@ -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);
     }
tools/firmware/hvmloader/acpi/build.c +1 -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++;
tools/firmware/hvmloader/acpi/build.c +1 -1
@@ -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++;
     }
tools/firmware/hvmloader/acpi/libacpi.h +0 -0
index 3bcd226..d803139 100644

tools/firmware/hvmloader/acpi/libacpi.h struct acpi_config { · line 89

Quoted 6 lines
tools/firmware/hvmloader/acpi/libacpi.h +3 -0
@@ -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
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw

Re: [PATCH v3 09/19] acpi/hvmloader: Include file/paths adjustments

Quoted 8 lines · Jan Beulich
Quoted 8 lines
tools/firmware/hvmloader/acpi/libacpi.h +0 -0
index 3bcd226..d803139 100644
@@ -84,6 +84,13 @@ struct acpi_config {
 
Quoted 11 lines

tools/firmware/hvmloader/acpi/libacpi.h struct acpi_config { · line 89

Quoted 5 lines
tools/firmware/hvmloader/acpi/libacpi.h +3 -0
     /* 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.

Quoted 4 lines

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
[email protected]
https://lists.xen.org/xen-devel

#16 lore raw

PATCH v3 10/19 acpi: Move ACPI code to tools/libacpi

In reply to Boris Ostrovsky
---
 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%)
MAINTAINERS +1 -0
index 97720a8..07545f3 100644
@@ -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 <[email protected]>
tools/firmware/hvmloader/Makefile +8 -6
index 77e95f1..9fa9bcc 100644
@@ -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
tools/firmware/hvmloader/ovmf.c +1 -1
index 0ac3416..4ff7f1d 100644
@@ -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"
tools/firmware/rombios/32bit/Makefile +1 -1
index 71399d2..b0583c9 100644
@@ -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
 
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
index 6822027..f87d130 100644
@@ -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)
tools/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +1 -1
similarity index 98%
rename from tools/firmware/hvmloader/acpi/Makefile
rename to tools/libacpi/Makefile
index f635f18..6325cd0 100644
@@ -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
tools/libacpi/README renamed from tools/firmware/hvmloader/acpi/README +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/README
rename to tools/libacpi/README
tools/libacpi/acpi2_0.h renamed from tools/firmware/hvmloader/acpi/acpi2_0.h +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/acpi2_0.h
rename to tools/libacpi/acpi2_0.h
tools/libacpi/build.c renamed from tools/firmware/hvmloader/acpi/build.c +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/build.c
rename to tools/libacpi/build.c
tools/libacpi/dsdt.asl renamed from tools/firmware/hvmloader/acpi/dsdt.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/dsdt.asl
rename to tools/libacpi/dsdt.asl
tools/libacpi/libacpi.h renamed from tools/firmware/hvmloader/acpi/libacpi.h +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/libacpi.h
rename to tools/libacpi/libacpi.h
tools/libacpi/mk_dsdt.c renamed from tools/firmware/hvmloader/acpi/mk_dsdt.c +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/mk_dsdt.c
rename to tools/libacpi/mk_dsdt.c
tools/libacpi/ssdt_pm.asl renamed from tools/firmware/hvmloader/acpi/ssdt_pm.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_pm.asl
rename to tools/libacpi/ssdt_pm.asl
tools/libacpi/ssdt_s3.asl renamed from tools/firmware/hvmloader/acpi/ssdt_s3.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s3.asl
rename to tools/libacpi/ssdt_s3.asl
tools/libacpi/ssdt_s4.asl renamed from tools/firmware/hvmloader/acpi/ssdt_s4.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s4.asl
rename to tools/libacpi/ssdt_s4.asl
tools/libacpi/ssdt_tpm.asl renamed from tools/firmware/hvmloader/acpi/ssdt_tpm.asl +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_tpm.asl
rename to tools/libacpi/ssdt_tpm.asl
tools/libacpi/static_tables.c renamed from tools/firmware/hvmloader/acpi/static_tables.c +0 -0
similarity index 100%
rename from tools/firmware/hvmloader/acpi/static_tables.c
rename to tools/libacpi/static_tables.c
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#17 lore raw

PATCH v3 11/19 x86: Allow LAPIC-only emulation_flags for HVM guests

In reply to Boris Ostrovsky

PVHv2 guests may request LAPIC emulation (and nothing else)

---
 xen/arch/x86/domain.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
xen/arch/x86/domain.c +16 -10
index 7ca1b66..135a7ae 100644
@@ -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) )
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#18 lore raw

PATCH v3 12/19 libacpi: Build DSDT for PVH guests

In reply to Boris Ostrovsky

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.

---
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
tools/libacpi/Makefile +10 -3
index 6325cd0..12b081e 100644
@@ -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 >$@
tools/libacpi/dsdt.asl +0 -20
index 895a8e5..715bd7a 100644
@@ -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
          */
tools/libacpi/dsdt_acpi_info.asl new file +26 -0
new file mode 100644
index 0000000..29e962a
@@ -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
+       }
+    }
tools/libacpi/mk_dsdt.c +8 -0
index bc414bf..30477fd 100644
@@ -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",
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#19 lore raw

Re: [PATCH v3 12/19] libacpi: Build DSDT for PVH guests

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:
tools/libacpi/Makefile +2 -1
@@ -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'

tools/libacpi/Makefile $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl · line 49

Quoted 10 lines
tools/libacpi/Makefile +6 -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
[email protected]
https://lists.xen.org/xen-devel

#20 lore raw

Re: [PATCH v3 12/19] libacpi: Build DSDT for PVH guests

In reply to Boris Ostrovsky
Quoted 24 lines · Boris Ostrovsky

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.

---
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
tools/libacpi/Makefile +0 -0
index 6325cd0..12b081e 100644

tools/libacpi/Makefile include $(XEN_ROOT)/tools/firmware/Rules.mk · line 23

Quoted 7 lines
tools/libacpi/Makefile +1 -1
@@ -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,

Signature · 7 lines
Shannon


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#21 lore raw

Re: [PATCH v3 12/19] libacpi: Build DSDT for PVH guests

Quoted 35 lines · Shannon Zhao
Quoted 24 lines · Boris Ostrovsky

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.

---
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
tools/libacpi/Makefile +0 -0
index 6325cd0..12b081e 100644

tools/libacpi/Makefile include $(XEN_ROOT)/tools/firmware/Rules.mk · line 23

Quoted 7 lines
tools/libacpi/Makefile +1 -1
@@ -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,

Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#22 lore raw

PATCH v3 13/19 acpi: Makefile should better tolerate interrupts

In reply to Boris Ostrovsky

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

---
New in v3

 tools/libacpi/Makefile | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
tools/libacpi/Makefile +23 -16
index 12b081e..2d8a954 100644
@@ -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
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#23 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

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

---
New in v3

Ah, here we go.

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 26

Quoted 9 lines
tools/libacpi/Makefile +3 -0
@@ -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?

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 30

Quoted 3 lines
tools/libacpi/Makefile +1 -0
 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
[email protected]
https://lists.xen.org/xen-devel

#24 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 15 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

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

---
New in v3

Ah, here we go.

Quoted 6 lines
tools/libacpi/Makefile +0 -0
@@ -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)
 
Quoted 5 lines

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 26

Quoted 3 lines
tools/libacpi/Makefile +3 -0
+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.

Quoted 9 lines

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 30

Quoted 4 lines
tools/libacpi/Makefile +1 -0
 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
[email protected]
https://lists.xen.org/xen-devel

#25 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 21

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:
tools/libacpi/Makefile +0 -0
@@ -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)

Quoted 1 line

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 22

Quoted 1 line
tools/libacpi/Makefile +0 -0
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h 

ssdt_tpm.h)

Quoted 6 lines

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 26

Quoted 4 lines
tools/libacpi/Makefile +3 -0
+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?

Quoted 3 lines

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

Quoted 9 lines
Quoted 8 lines

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 30

Quoted 3 lines
tools/libacpi/Makefile +1 -0
 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.

Quoted 4 lines

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

Quoted 9 lines

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
[email protected]
https://lists.xen.org/xen-devel

#26 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 21

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:
tools/libacpi/Makefile +0 -0
@@ -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)

Quoted 1 line

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 22

Quoted 1 line
tools/libacpi/Makefile +0 -0
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h 

ssdt_tpm.h)

Quoted 6 lines

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 26

Quoted 4 lines
tools/libacpi/Makefile +3 -0
+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?

Quoted 7 lines
Quoted 3 lines

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.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 30

Quoted 4 lines
tools/libacpi/Makefile +1 -0
 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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 3 lines

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

Quoted 3 lines

(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

Quoted 8 lines
Quoted 8 lines

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

Quoted 6 lines
Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#27 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:07, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 30

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

vpath iasl $(PATH)
all: $(C_SRC) $(H_SRC)

tools/libacpi/Makefile +1 -0
+	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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 6 lines

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?

Quoted 7 lines
Quoted 3 lines

(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
[email protected]
https://lists.xen.org/xen-devel

#28 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:07, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

tools/libacpi/Makefile MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt · line 30

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

vpath iasl $(PATH)
all: $(C_SRC) $(H_SRC)

tools/libacpi/Makefile +1 -0
+	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.

Quoted 4 lines

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.

Quoted 7 lines
Quoted 6 lines

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
[email protected]
https://lists.xen.org/xen-devel

#29 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):

Quoted 4 lines · Jan Beulich
Quoted 1 line

Then my suggestion of using relative paths would still help?

Apparently it doesn't like any dots:

...

Quoted 6 lines

[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

Quoted 6 lines

/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
[email protected]
https://lists.xen.org/xen-devel

#30 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 14 lines · Ian Jackson

Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):

Quoted 3 lines · Jan Beulich
Quoted 1 line

Then my suggestion of using relative paths would still help?

Apparently it doesn't like any dots:

...

Quoted 9 lines

[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:
. ..

Quoted 8 lines
Quoted 3 lines

/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
[email protected]
https://lists.xen.org/xen-devel

#31 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):

Quoted 1 line

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
[email protected]
https://lists.xen.org/xen-devel

#32 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 6 lines · Ian Jackson

Boris Ostrovsky writes ("Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts"):

Quoted 1 line

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
[email protected]
https://lists.xen.org/xen-devel

#33 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

In reply to Boris Ostrovsky
Quoted 38 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:56, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:07, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

Review

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

vpath iasl $(PATH)
all: $(C_SRC) $(H_SRC)

(quoted diff) +1 -0
+	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.

Quoted 4 lines

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.

Quoted 7 lines
Quoted 6 lines

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

Quoted 6 lines

/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
[email protected]
https://lists.xen.org/xen-devel

#34 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 37 lines · Jan Beulich
Quoted 37 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:56, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:07, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

Review

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

vpath iasl $(PATH)
all: $(C_SRC) $(H_SRC)

(quoted diff) +1 -0
+	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.

Quoted 4 lines

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.

Quoted 7 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 6 lines

/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
[email protected]
https://lists.xen.org/xen-devel

#35 lore raw

Re: [PATCH v3 13/19] acpi: Makefile should better tolerate interrupts

Quoted 42 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 18:05, <[email protected]> wrote:
Quoted 40 lines · Jan Beulich
Quoted 40 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:56, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 09.09.16 at 15:07, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:51, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

Review

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

vpath iasl $(PATH)
all: $(C_SRC) $(H_SRC)

(quoted diff) +1 -0
+	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.

Quoted 4 lines

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.

Quoted 7 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

/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
[email protected]
https://lists.xen.org/xen-devel

#36 lore raw

PATCH v3 14/19 libxc/libxl: Allow multiple ACPI modules

In reply to Boris Ostrovsky

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.

---
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(-)
tools/libxc/include/xc_dom.h +3 -2
index de7dca9..608cbc2 100644
@@ -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;
tools/libxc/xc_dom_hvmloader.c +2 -1
index 6eb8516..59f94e5 100644
@@ -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;
tools/libxl/libxl_dom.c +18 -8
index c895649..c4be916 100644
@@ -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;
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v3 14/19
#37 lore raw

Re: [PATCH v3 14/19] libxc/libxl: Allow multiple ACPI modules

Quoted 8 lines · Boris Ostrovsky

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#38 lore raw

PATCH v3 15/19 libxl/acpi: Add ACPI e820 entry

In reply to Boris Ostrovsky

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

---
Changes in v3:
* format adjustments

 tools/libxl/libxl_dom.c |  8 ++++----
 tools/libxl/libxl_x86.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)
tools/libxl/libxl_dom.c +4 -4
index c4be916..7974302 100644
@@ -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,
tools/libxl/libxl_x86.c +15 -0
index 46cfafb..2b221aa 100644
@@ -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);
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#40 lore raw

PATCH v3 16/19 libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests

In reply to Boris Ostrovsky

---
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(-)
tools/libxl/Makefile +2 -0
index 14a1a8e..1f3b40f 100644
@@ -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)
 
tools/libxl/libxl_arch.h +6 -0
index 34a853c..253a037 100644
@@ -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
tools/libxl/libxl_dom.c +15 -4
index 7974302..2924629 100644
@@ -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;
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#42 lore raw

PATCH v3 17/19 ilibxl: Initialize domain build info before calling libxl__domain_make

In reply to Boris Ostrovsky

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

---
 tools/libxl/libxl_create.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
tools/libxl/libxl_create.c +11 -11
index 04f8ae9..07b2b4b 100644
@@ -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.
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#44 lore raw

PATCH v3 18/19 libxl/acpi: Build ACPI tables for HVMlite guests

In reply to Boris Ostrovsky

---
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
.gitignore +8 -4
index 9b2c405..9f5bd8c 100644
@@ -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
tools/libacpi/build.c +4 -3
index 1cd640d..ee5f779 100644
@@ -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;
 }
 
 /*
tools/libacpi/libacpi.h +12 -3
index d803139..b0ff5aa 100644
@@ -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__ */
 
tools/libxl/Makefile +17 -1
index 1f3b40f..ee32bc7 100644
@@ -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
tools/libxl/libxl_arch.h +3 -0
index 253a037..7a70b01 100644
@@ -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
tools/libxl/libxl_x86.c +21 -9
index 2b221aa..d10b04b 100644
@@ -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. */
tools/libxl/libxl_x86_acpi.c new file +218 -0

218 lines not on this page · raw message

tools/libxl/libxl_x86_acpi.h new file +35 -0
new file mode 100644
index 0000000..17a8bd4
@@ -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:
+ */
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#45 lore raw

Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 99 lines
Quoted 1 line
Quoted 1 line · On 07.09.16 at 20:59, <[email protected]> wrote:

---
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
.gitignore +8 -4
index 9b2c405..9f5bd8c 100644
@@ -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
tools/libacpi/build.c +4 -3
index 1cd640d..ee5f779 100644
@@ -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;
 }
 

/*

tools/libacpi/libacpi.h +0 -0
index d803139..b0ff5aa 100644
@@ -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;

tools/libacpi/libacpi.h struct acpi_ctxt { · line 60

Quoted 10 lines
tools/libacpi/libacpi.h +9 -0
+
+    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
[email protected]
https://lists.xen.org/xen-devel

#46 lore raw

Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 18 lines · Jan Beulich
Quoted 18 lines

/*

tools/libacpi/libacpi.h +7 -0
index d803139..b0ff5aa 100644
@@ -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;
Quoted 8 lines

tools/libacpi/libacpi.h struct acpi_ctxt { · line 60

Quoted 3 lines
tools/libacpi/libacpi.h +2 -0
+    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
[email protected]
https://lists.xen.org/xen-devel

#47 lore raw

Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:53, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
tools/libacpi/libacpi.h +7 -0
@@ -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;
Quoted 8 lines

tools/libacpi/libacpi.h struct acpi_ctxt { · line 60

Quoted 3 lines
tools/libacpi/libacpi.h +2 -0
+    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.

Quoted 7 lines
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
[email protected]
https://lists.xen.org/xen-devel

#48 lore raw

Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 32 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 08.09.16 at 20:53, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
tools/libacpi/libacpi.h +7 -0
@@ -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;
Quoted 8 lines

tools/libacpi/libacpi.h struct acpi_ctxt { · line 60

Quoted 3 lines
tools/libacpi/libacpi.h +2 -0
+    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.

Quoted 7 lines
struct acpi_ctxt {
    ...

    void *private;
};

?

That's one option; I'd prefer

Quoted 7 lines
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
[email protected]
https://lists.xen.org/xen-devel

#49 lore raw

Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests

Boris Ostrovsky writes ("Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests"):

Quoted 11 lines · Jan Beulich
Quoted 7 lines
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
[email protected]
https://lists.xen.org/xen-devel

#50 lore raw

Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests

Quoted 7 lines · Ian Jackson

Boris Ostrovsky writes ("Re: [PATCH v3 18/19] libxl/acpi: Build ACPI tables for HVMlite guests"):

Quoted 6 lines · Jan Beulich
Quoted 5 lines
struct libxl_acpi_ctxt {
    struct acpi_ctxt ctxt;
    ...
};
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#51 lore raw

PATCH v3 19/19 libxc/xc_dom_core: Copy ACPI tables to guest space

In reply to Boris Ostrovsky

Load ACPI modules into guest space

---
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(+)
tools/libxc/xc_dom_core.c +93 -0
index ebada89..3817eb8 100644
@@ -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 ||
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#52 lore raw

Re: [PATCH v3 19/19] libxc/xc_dom_core: Copy ACPI tables to guest space

Quoted 3 lines · Boris Ostrovsky

Load ACPI modules into guest space

Some coding style issues are found.

Quoted 31 lines

---
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(+)
tools/libxc/xc_dom_core.c +15 -0
index ebada89..3817eb8 100644
@@ -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;

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1067

Quoted 10 lines
tools/libxc/xc_dom_core.c +10 -0
+
+        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.

Quoted 24 lines
tools/libxc/xc_dom_core.c +24 -0
+        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)) >>

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1101

Quoted 10 lines
tools/libxc/xc_dom_core.c +10 -0
+                       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.

tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1111

Quoted 10 lines
tools/libxc/xc_dom_core.c +10 -0
+            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.

Quoted 37 lines
tools/libxc/xc_dom_core.c +24 -0
+        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 ||
Signature · 1 line
1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#53 lore raw
In reply to Boris Ostrovsky
Quoted 5 lines · Boris Ostrovsky

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?

Quoted 4 lines

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
[email protected]
https://lists.xen.org/xen-devel

#54 lore raw
Quoted 22 lines · Boris Ostrovsky
Quoted 5 lines · Boris Ostrovsky

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?

Quoted 4 lines

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.

Quoted 4 lines

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.

Quoted 3 lines

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#55 lore raw

Hi Wei,

Quoted 23 lines · Wei Liu
Quoted 22 lines · Boris Ostrovsky
Quoted 5 lines · Boris Ostrovsky

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?

Quoted 4 lines

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.

Quoted 7 lines
Quoted 4 lines

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,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#56 lore raw
Quoted 31 lines · Julien Grall

Hi Wei,

Quoted 28 lines · Wei Liu
Quoted 26 lines · Boris Ostrovsky
Quoted 5 lines · Boris Ostrovsky

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?

Quoted 4 lines

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 4 lines

Cheers,

Signature · 1 line
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#57 lore raw
Quoted 30 lines · Wei Liu
Quoted 29 lines · Julien Grall

Hi Wei,

Quoted 26 lines · Wei Liu
Quoted 19 lines · Boris Ostrovsky
Quoted 5 lines · Boris Ostrovsky

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?

Quoted 3 lines

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.

Quoted 4 lines

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.

Quoted 7 lines
Quoted 3 lines

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
[email protected]
https://lists.xen.org/xen-devel

#58 lore raw

Hi Boris,

Quoted 39 lines · Boris Ostrovsky
Quoted 30 lines · Wei Liu
Quoted 29 lines · Julien Grall

Hi Wei,

Quoted 26 lines · Wei Liu
Quoted 19 lines · Boris Ostrovsky
Quoted 5 lines · Boris Ostrovsky

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?

Quoted 3 lines

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.

Quoted 4 lines

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.

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#59 lore raw
Quoted 56 lines · Julien Grall

Hi Boris,

Quoted 53 lines · Boris Ostrovsky
Quoted 42 lines · Wei Liu
Quoted 34 lines · Julien Grall

Hi Wei,

Quoted 31 lines · Wei Liu
Quoted 30 lines · Boris Ostrovsky
Quoted 8 lines · Boris Ostrovsky

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?

Quoted 4 lines

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.

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

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.

Quoted 5 lines
Quoted 1 line

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
[email protected]
https://lists.xen.org/xen-devel

#60 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 15.09.16 at 16:07, <[email protected]> wrote:
Quoted 7 lines · Julien Grall
Quoted 5 lines · Boris Ostrovsky

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.

Quoted 7 lines
Quoted 3 lines

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
[email protected]
https://lists.xen.org/xen-devel

#61 lore raw
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 15.09.16 at 16:07, <[email protected]> wrote:
Quoted 10 lines · Julien Grall
Quoted 5 lines · Boris Ostrovsky

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.

Quoted 7 lines
Quoted 2 lines

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

Quoted 1 line

From 15149f5d6ac15d7e7da650259dfcfaf4097b03ae Mon Sep 17 00:00:00 2001

From: Boris Ostrovsky <[email protected]>
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.

---
 tools/firmware/hvmloader/Makefile |  4 ++--
 tools/libacpi/Makefile            |  9 ++++++---
 tools/libacpi/mk_dsdt.c           | 10 ++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/tools/firmware/hvmloader/Makefile
index 9fa9bcc..dc21cdf 100644

tools/firmware/hvmloader/Makefile +2 -2
@@ -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
tools/libacpi/Makefile +0 -1
index 2d8a954..2fe14d4 100644
@@ -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)

tools/libacpi/mk_dsdt.c +7 -0
index 30477fd..c79e95f 100644
@@ -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:

Signature · 1 line
1.8.3.1
Quoted 1 line

From 15149f5d6ac15d7e7da650259dfcfaf4097b03ae Mon Sep 17 00:00:00 2001

From: Boris Ostrovsky <[email protected]>
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.

---
 tools/firmware/hvmloader/Makefile |  4 ++--
 tools/libacpi/Makefile            |  9 ++++++---
 tools/libacpi/mk_dsdt.c           | 10 ++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)
tools/firmware/hvmloader/Makefile +2 -2
index 9fa9bcc..dc21cdf 100644
@@ -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
tools/libacpi/Makefile +6 -3
index 2d8a954..2fe14d4 100644
@@ -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)
tools/libacpi/mk_dsdt.c +10 -0
index 30477fd..c79e95f 100644
@@ -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:
Signature · 1 line
1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#62 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 15.09.16 at 17:28, <[email protected]> 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).

Quoted 1 line

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
[email protected]
https://lists.xen.org/xen-devel

#63 lore raw

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

Quoted 2 lines
Quoted 1 line

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.

Quoted 3 lines

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.

Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#64 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 15.09.16 at 18:40, <[email protected]> wrote:

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

Quoted 2 lines
Quoted 1 line

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.

Quoted 6 lines
Quoted 3 lines

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.

Quoted 8 lines
Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#65 lore raw
Quoted 11 lines · Jan Beulich
Quoted 8 lines
Quoted 3 lines

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
[email protected]
https://lists.xen.org/xen-devel

#66 lore raw
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 3 lines

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.

Quoted 7 lines
Quoted 4 lines

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.

Quoted 4 lines

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?

Quoted 3 lines

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

Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#67 lore raw
Quoted 25 lines · Lars Kurth
Quoted 9 lines · Boris Ostrovsky
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 2 lines

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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 8 lines
Quoted 4 lines

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

Quoted 7 lines

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.

Quoted 5 lines

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.

Quoted 7 lines

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.

Quoted 8 lines
Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel

#68 lore raw

Boris Ostrovsky writes ("Re: [Xen-devel] [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader"):

Quoted 4 lines

_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
[email protected]
https://lists.xen.org/xen-devel

#69 lore raw
Quoted 8 lines · Ian Jackson

Boris Ostrovsky writes ("Re: [Xen-devel] [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader"):

Quoted 4 lines

_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
[email protected]
https://lists.xen.org/xen-devel

#70 lore raw

Boris Ostrovsky writes ("Re: [Xen-devel] [PATCH v3 00/19] Make ACPI builder available to components other than hvmloader"):

Quoted 2 lines

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
[email protected]
https://lists.xen.org/xen-devel