All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader
@ 2016-09-20  0:19 Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file Boris Ostrovsky
                   ` (20 more replies)
  0 siblings, 21 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

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

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

The most "interesting" part here (besides addressing v3 comments) is working around
licensing issues. This is mostly patch 2.

Boris Ostrovsky (21):
  acpi: Extract acpi info description into a separate ASL file
  acpi: Prevent GPL-only code from seeping into non-GPL binaries
  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                  |  24 +-
 tools/firmware/hvmloader/acpi/Makefile             |  72 --
 tools/firmware/hvmloader/acpi/dsdt.asl             | 480 ------------
 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                    |  52 +-
 tools/firmware/hvmloader/util.h                    |   2 +-
 tools/firmware/rombios/32bit/Makefile              |   2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile      |   2 +-
 tools/firmware/rombios/32bit/util.h                |   2 +-
 tools/libacpi/Makefile                             |  84 ++
 tools/{firmware/hvmloader/acpi => libacpi}/README  |  16 +-
 .../{firmware/hvmloader/acpi => libacpi}/acpi2_0.h |  19 +-
 tools/{firmware/hvmloader/acpi => libacpi}/build.c | 303 ++++----
 tools/libacpi/dsdt_acpi_info.asl                   |  26 +
 tools/libacpi/gpl/COPYING                          |   5 +
 tools/libacpi/gpl/dsdt.asl                         | 846 +++++++++++++++++++++
 .../{firmware/hvmloader/acpi => libacpi}/libacpi.h |  37 +-
 .../{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c |  88 +--
 .../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                          |  95 +++
 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                       | 243 ++++++
 tools/libxl/libxl_x86_acpi.h                       |  35 +
 xen/arch/x86/domain.c                              |  26 +-
 41 files changed, 1847 insertions(+), 912 deletions(-)
 delete mode 100644 tools/firmware/hvmloader/acpi/Makefile
 delete mode 100644 tools/firmware/hvmloader/acpi/dsdt.asl
 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%)
 create mode 100644 tools/libacpi/dsdt_acpi_info.asl
 create mode 100644 tools/libacpi/gpl/COPYING
 create mode 100644 tools/libacpi/gpl/dsdt.asl
 rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (64%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (82%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (97%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (62%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (62%)
 create mode 100644 tools/libacpi/ssdt_tpm.asl
 rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (90%)
 create mode 100644 tools/libxl/libxl_x86_acpi.c
 create mode 100644 tools/libxl/libxl_x86_acpi.h

-- 
1.8.3.1


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

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

* [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-21 10:29   ` Jan Beulich
  2016-09-20  0:19 ` [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries Boris Ostrovsky
                   ` (19 subsequent siblings)
  20 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

This code will be needed by PVH guests who don't want to use full DSDT.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* New patch. This used to be done in a later patch but because we now
  are trying to keep dsdt.asl GPL-only (in the next patch) it's better
  to do this here and not touch dsdt.asl later.

 .gitignore                                       |  2 +-
 tools/firmware/hvmloader/acpi/Makefile           |  8 +++++---
 tools/firmware/hvmloader/acpi/dsdt.asl           | 19 -----------------
 tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl | 26 ++++++++++++++++++++++++
 4 files changed, 32 insertions(+), 23 deletions(-)
 create mode 100644 tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl

diff --git a/.gitignore b/.gitignore
index cc64fc9..6dee857 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,7 +129,7 @@ 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/dsdt_*cpu*.asl
 tools/firmware/hvmloader/acpi/ssdt_*.h
 tools/firmware/hvmloader/hvmloader
 tools/firmware/hvmloader/roms.h
diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/firmware/hvmloader/acpi/Makefile
index d3e882a..76da073 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/firmware/hvmloader/acpi/Makefile
@@ -33,13 +33,15 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
 mk_dsdt: mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
+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'
-dsdt_%cpu.asl: dsdt.asl mk_dsdt
+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 $*  >> $@
 
 $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
@@ -63,7 +65,7 @@ acpi.a: $(OBJS)
 
 clean:
 	rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
-	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
+	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*cpu*.asl
 
 distclean: clean
 
diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl
index bd65823..4f6db79 100644
--- a/tools/firmware/hvmloader/acpi/dsdt.asl
+++ b/tools/firmware/hvmloader/acpi/dsdt.asl
@@ -43,25 +43,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
 
     Scope (\_SB)
     {
-       /* ACPI_INFO_PHYSICAL_ADDRESS == 0xFC000000 */
-       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
-       Field(BIOS, ByteAcc, NoLock, Preserve) {
-           UAR1, 1,
-           UAR2, 1,
-           LTP1, 1,
-           HPET, 1,
-           Offset(2),
-           NCPU, 16,
-           PMIN, 32,
-           PLEN, 32,
-           MSUA, 32, /* MADT checksum address */
-           MAPA, 32, /* MADT LAPIC0 address */
-           VGIA, 32, /* VM generation id address */
-           LMIN, 32,
-           HMIN, 32,
-           LLEN, 32,
-           HLEN, 32
-       }
 
         /* Fix HCT test for 0x400 pci memory:
          * - need to report low 640 MB mem as motherboard resource
diff --git a/tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl b/tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl
new file mode 100644
index 0000000..29e962a
--- /dev/null
+++ b/tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl
@@ -0,0 +1,26 @@
+
+    Scope (\_SB)
+    {
+       /*
+        * BIOS region must match struct acpi_info in build.c and
+	* be located at ACPI_INFO_PHYSICAL_ADDRESS = 0xFC000000
+	*/
+       OperationRegion(BIOS, SystemMemory, 0xFC000000, 40)
+       Field(BIOS, ByteAcc, NoLock, Preserve) {
+           UAR1, 1,
+           UAR2, 1,
+           LTP1, 1,
+           HPET, 1,
+           Offset(2),
+           NCPU, 16,
+           PMIN, 32,
+           PLEN, 32,
+           MSUA, 32, /* MADT checksum address */
+           MAPA, 32, /* MADT LAPIC0 address */
+           VGIA, 32, /* VM generation id address */
+           LMIN, 32,
+           HMIN, 32,
+           LLEN, 32,
+           HLEN, 32
+       }
+    }
-- 
1.8.3.1


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

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

* [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-20 10:14   ` Ian Jackson
                     ` (2 more replies)
  2016-09-20  0:19 ` [PATCH v4 03/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
                   ` (18 subsequent siblings)
  20 siblings, 3 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, ian.jackson, julien.grall,
	jbeulich, zhaoshenglong, Boris Ostrovsky, roger.pau

Some code (specifically, introduced by commit 801d469ad ("[HVM] ACPI
support patch 3 of 4: ACPI _PRT table.")) has only been licensed under
GPLv2. We want to prevent this code from showing up in non-GPL
binaries which might become possible after we make ACPI builder code
available to users other than hvmloader.

There are two pieces that we need to be careful about:
(1) A small piece of code in dsdt.asl that implements _PIC method
(2) A fragment of ASL generator in mk_dsdt.c that describes PCI
    interrupt routing.

The cleanest way to deal with this seems to be taking generatedi ASL
chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
CC: Lars Kurth <lars.kurth@citrix.com>
---

Changes in v4:
* New in v4
  Added code in new dsdt.asl is
  +    Scope ( \_SB.PCI0 )
  +    {
  +        Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
           ...
  +        })
  +    }

 tools/firmware/hvmloader/Makefile          |   4 +
 tools/firmware/hvmloader/acpi/Makefile     |   9 +-
 tools/firmware/hvmloader/acpi/dsdt.asl     | 461 ----------------
 tools/firmware/hvmloader/acpi/gpl/COPYING  |   5 +
 tools/firmware/hvmloader/acpi/gpl/dsdt.asl | 846 +++++++++++++++++++++++++++++
 tools/firmware/hvmloader/acpi/mk_dsdt.c    |  68 +--
 6 files changed, 862 insertions(+), 531 deletions(-)
 delete mode 100644 tools/firmware/hvmloader/acpi/dsdt.asl
 create mode 100644 tools/firmware/hvmloader/acpi/gpl/COPYING
 create mode 100644 tools/firmware/hvmloader/acpi/gpl/dsdt.asl

diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 9f7357f..23b0a58 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -65,6 +65,10 @@ ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
 ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
 endif
 
+# Certain parts of ACPI builder are GPL-only
+GPL = y
+export GPL
+
 .PHONY: all
 all: subdirs-all
 	$(MAKE) hvmloader
diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/firmware/hvmloader/acpi/Makefile
index 76da073..32d8c22 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/firmware/hvmloader/acpi/Makefile
@@ -17,7 +17,8 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
+C_SRC-$(GPL) 	= build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+C_SRC		= build.c static_tables.c $(C_SRC-y)
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
 CFLAGS += $(CFLAGS_xeninclude)
@@ -33,16 +34,18 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
 mk_dsdt: mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt
+ifeq ($(GPL),y)
+dsdt_anycpu_qemu_xen.asl: gpl/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'
-dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt
+dsdt_%cpu.asl: gpl/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 $*  >> $@
+endif
 
 $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
 	iasl -vs -p $* -tc $*.asl
diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl
deleted file mode 100644
index 4f6db79..0000000
--- a/tools/firmware/hvmloader/acpi/dsdt.asl
+++ /dev/null
@@ -1,461 +0,0 @@
-/******************************************************************************
- * DSDT for Xen with Qemu device model
- *
- * 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/>.
- */
-
-DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
-{
-    Name (\PMBS, 0x0C00)
-    Name (\PMLN, 0x08)
-    Name (\IOB1, 0x00)
-    Name (\IOL1, 0x00)
-    Name (\APCB, 0xFEC00000)
-    Name (\APCL, 0x00010000)
-    Name (\PUID, 0x00)
-
-    /* _S3 and _S4 are in separate SSDTs */
-    Name (\_S5, Package (0x04)
-    {
-        0x00,  /* PM1a_CNT.SLP_TYP */
-        0x00,  /* PM1b_CNT.SLP_TYP */
-        0x00,  /* reserved */
-        0x00   /* reserved */
-    })
-
-    Name(PICD, 0)
-    Method(_PIC, 1)
-    {
-        Store(Arg0, PICD) 
-    }
-
-    Scope (\_SB)
-    {
-
-        /* Fix HCT test for 0x400 pci memory:
-         * - need to report low 640 MB mem as motherboard resource
-         */
-       Device(MEM0)
-       {
-           Name(_HID, EISAID("PNP0C02"))
-           Name(_CRS, ResourceTemplate() {
-               QWordMemory(
-                    ResourceConsumer, PosDecode, MinFixed,
-                    MaxFixed, Cacheable, ReadWrite,
-                    0x00000000,
-                    0x00000000,
-                    0x0009ffff,
-                    0x00000000,
-                    0x000a0000)
-           })
-       }
-
-       Device (PCI0)
-       {
-           Name (_HID, EisaId ("PNP0A03"))
-           Name (_UID, 0x00)
-           Name (_ADR, 0x00)
-           Name (_BBN, 0x00)
-
-           /* Make cirrues VGA S3 suspend/resume work in Windows XP/2003 */
-           Device (VGA)
-           {
-               Name (_ADR, 0x00020000)
-
-               Method (_S1D, 0, NotSerialized)
-               {
-                   Return (0x00)
-               }
-               Method (_S2D, 0, NotSerialized)
-               {
-                   Return (0x00)
-               }
-               Method (_S3D, 0, NotSerialized)
-               {
-                   Return (0x00)
-               }
-           }
-
-           Method (_CRS, 0, NotSerialized)
-           {
-               Store (ResourceTemplate ()
-               {
-                   /* bus number is from 0 - 255*/
-                   WordBusNumber(
-                        ResourceProducer, MinFixed, MaxFixed, SubDecode,
-                        0x0000,
-                        0x0000,
-                        0x00FF,
-                        0x0000,
-                        0x0100)
-                    IO (Decode16, 0x0CF8, 0x0CF8, 0x01, 0x08)
-                    WordIO(
-                        ResourceProducer, MinFixed, MaxFixed, PosDecode,
-                        EntireRange,
-                        0x0000,
-                        0x0000,
-                        0x0CF7,
-                        0x0000,
-                        0x0CF8)
-                    WordIO(
-                        ResourceProducer, MinFixed, MaxFixed, PosDecode,
-                        EntireRange,
-                        0x0000,
-                        0x0D00,
-                        0xFFFF,
-                        0x0000,
-                        0xF300)
-
-                    /* reserve memory for pci devices */
-                    DWordMemory(
-                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
-                        WriteCombining, ReadWrite,
-                        0x00000000,
-                        0x000A0000,
-                        0x000BFFFF,
-                        0x00000000,
-                        0x00020000)
-
-                    DWordMemory(
-                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
-                        NonCacheable, ReadWrite,
-                        0x00000000,
-                        0xF0000000,
-                        0xF4FFFFFF,
-                        0x00000000,
-                        0x05000000,
-                        ,, _Y01)
-
-                    QWordMemory (
-                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
-                        NonCacheable, ReadWrite,
-                        0x0000000000000000,
-                        0x0000000FFFFFFFF0,
-                        0x0000000FFFFFFFFF,
-                        0x0000000000000000,
-                        0x0000000000000010,
-                        ,, _Y02)
-
-                }, Local1)
-
-                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._MIN, MMIN)
-                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._MAX, MMAX)
-                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._LEN, MLEN)
-
-                Store(\_SB.PMIN, MMIN)
-                Store(\_SB.PLEN, MLEN)
-                Add(MMIN, MLEN, MMAX)
-                Subtract(MMAX, One, MMAX)
-
-                /*
-                 * WinXP / Win2K3 blue-screen for operations on 64-bit values.
-                 * Therefore we need to split the 64-bit calculations needed
-                 * here, but different iasl versions evaluate name references
-                 * to integers differently:
-                 * Year (approximate)          2006    2008    2012
-                 * \_SB.PCI0._CRS._Y02         zero   valid   valid
-                 * \_SB.PCI0._CRS._Y02._MIN   valid   valid    huge
-                 */
-                If(LEqual(Zero, \_SB.PCI0._CRS._Y02)) {
-                    Subtract(\_SB.PCI0._CRS._Y02._MIN, 14, Local0)
-                } Else {
-                    Store(\_SB.PCI0._CRS._Y02, Local0)
-                }
-                CreateDWordField(Local1, Add(Local0, 14), MINL)
-                CreateDWordField(Local1, Add(Local0, 18), MINH)
-                CreateDWordField(Local1, Add(Local0, 22), MAXL)
-                CreateDWordField(Local1, Add(Local0, 26), MAXH)
-                CreateDWordField(Local1, Add(Local0, 38), LENL)
-                CreateDWordField(Local1, Add(Local0, 42), LENH)
-
-                Store(\_SB.LMIN, MINL)
-                Store(\_SB.HMIN, MINH)
-                Store(\_SB.LLEN, LENL)
-                Store(\_SB.HLEN, LENH)
-                Add(MINL, LENL, MAXL)
-                Add(MINH, LENH, MAXH)
-                If(LLess(MAXL, MINL)) {
-                    Add(MAXH, One, MAXH)
-                }
-                If(LOr(MINH, LENL)) {
-                    If(LEqual(MAXL, 0)) {
-                        Subtract(MAXH, One, MAXH)
-                    }
-                    Subtract(MAXL, One, MAXL)
-                }
-
-                Return (Local1)
-            }
-
-            Device(HPET) {
-                Name(_HID,  EISAID("PNP0103"))
-                Name(_UID, 0)
-                Method (_STA, 0, NotSerialized) {
-                    If(LEqual(\_SB.HPET, 0)) {
-                        Return(0x00)
-                    } Else {
-                        Return(0x0F)
-                    }
-                }
-                Name(_CRS, ResourceTemplate() {
-                    DWordMemory(
-                        ResourceConsumer, PosDecode, MinFixed, MaxFixed,
-                        NonCacheable, ReadWrite,
-                        0x00000000,
-                        0xFED00000,
-                        0xFED003FF,
-                        0x00000000,
-                        0x00000400 /* 1K memory: FED00000 - FED003FF */
-                    )
-                })
-            }
-
-            Device (ISA)
-            {
-                Name (_ADR, 0x00010000) /* device 1, fn 0 */
-
-                OperationRegion(PIRQ, PCI_Config, 0x60, 0x4)
-                Scope(\) {
-                    Field (\_SB.PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
-                        PIRA, 8,
-                        PIRB, 8,
-                        PIRC, 8,
-                        PIRD, 8
-                    }
-                }
-                Device (SYSR)
-                {
-                    Name (_HID, EisaId ("PNP0C02"))
-                    Name (_UID, 0x01)
-                    Name (CRS, ResourceTemplate ()
-                    {
-                        /* TODO: list hidden resources */
-                        IO (Decode16, 0x0010, 0x0010, 0x00, 0x10)
-                        IO (Decode16, 0x0022, 0x0022, 0x00, 0x0C)
-                        IO (Decode16, 0x0030, 0x0030, 0x00, 0x10)
-                        IO (Decode16, 0x0044, 0x0044, 0x00, 0x1C)
-                        IO (Decode16, 0x0062, 0x0062, 0x00, 0x02)
-                        IO (Decode16, 0x0065, 0x0065, 0x00, 0x0B)
-                        IO (Decode16, 0x0072, 0x0072, 0x00, 0x0E)
-                        IO (Decode16, 0x0080, 0x0080, 0x00, 0x01)
-                        IO (Decode16, 0x0084, 0x0084, 0x00, 0x03)
-                        IO (Decode16, 0x0088, 0x0088, 0x00, 0x01)
-                        IO (Decode16, 0x008C, 0x008C, 0x00, 0x03)
-                        IO (Decode16, 0x0090, 0x0090, 0x00, 0x10)
-                        IO (Decode16, 0x00A2, 0x00A2, 0x00, 0x1C)
-                        IO (Decode16, 0x00E0, 0x00E0, 0x00, 0x10)
-                        IO (Decode16, 0x08A0, 0x08A0, 0x00, 0x04)
-                        IO (Decode16, 0x0CC0, 0x0CC0, 0x00, 0x10)
-                        IO (Decode16, 0x04D0, 0x04D0, 0x00, 0x02)
-                    })
-                    Method (_CRS, 0, NotSerialized)
-                    {
-                        Return (CRS)
-                    }
-                }
-
-                Device (PIC)
-                {
-                    Name (_HID, EisaId ("PNP0000"))
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IO (Decode16, 0x0020, 0x0020, 0x01, 0x02)
-                        IO (Decode16, 0x00A0, 0x00A0, 0x01, 0x02)
-                        IRQNoFlags () {2}
-                    })
-                }
-
-                Device (DMA0)
-                {
-                    Name (_HID, EisaId ("PNP0200"))
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        DMA (Compatibility, BusMaster, Transfer8) {4}
-                        IO (Decode16, 0x0000, 0x0000, 0x00, 0x10)
-                        IO (Decode16, 0x0081, 0x0081, 0x00, 0x03)
-                        IO (Decode16, 0x0087, 0x0087, 0x00, 0x01)
-                        IO (Decode16, 0x0089, 0x0089, 0x00, 0x03)
-                        IO (Decode16, 0x008F, 0x008F, 0x00, 0x01)
-                        IO (Decode16, 0x00C0, 0x00C0, 0x00, 0x20)
-                        IO (Decode16, 0x0480, 0x0480, 0x00, 0x10)
-                    })
-                }
-
-                Device (TMR)
-                {
-                    Name (_HID, EisaId ("PNP0100"))
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IO (Decode16, 0x0040, 0x0040, 0x00, 0x04)
-                        IRQNoFlags () {0}
-                    })
-                }
-
-                Device (RTC)
-                {
-                    Name (_HID, EisaId ("PNP0B00"))
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IO (Decode16, 0x0070, 0x0070, 0x00, 0x02)
-                        IRQNoFlags () {8}
-                    })
-                }
-
-                Device (SPKR)
-                {
-                    Name (_HID, EisaId ("PNP0800"))
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IO (Decode16, 0x0061, 0x0061, 0x00, 0x01)
-                    })
-                }
-
-                Device (PS2M)
-                {
-                    Name (_HID, EisaId ("PNP0F13"))
-                    Name (_CID, 0x130FD041)
-                    Method (_STA, 0, NotSerialized)
-                    {
-                        Return (0x0F)
-                    }
-
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IRQNoFlags () {12}
-                    })
-                }
-
-                Device (PS2K)
-                {
-                    Name (_HID, EisaId ("PNP0303"))
-                    Name (_CID, 0x0B03D041)
-                    Method (_STA, 0, NotSerialized)
-                    {
-                        Return (0x0F)
-                    }
-
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IO (Decode16, 0x0060, 0x0060, 0x00, 0x01)
-                        IO (Decode16, 0x0064, 0x0064, 0x00, 0x01)
-                        IRQNoFlags () {1}
-                    })
-                }
-
-                Device (FDC0)
-                {
-                    Name (_HID, EisaId ("PNP0700"))
-                    Method (_STA, 0, NotSerialized)
-                    {
-                          Return (0x0F)
-                    }
-
-                    Name (_CRS, ResourceTemplate ()
-                    {
-                        IO (Decode16, 0x03F0, 0x03F0, 0x01, 0x06)
-                        IO (Decode16, 0x03F7, 0x03F7, 0x01, 0x01)
-                        IRQNoFlags () {6}
-                        DMA (Compatibility, NotBusMaster, Transfer8) {2}
-                    })
-                }
-
-                Device (UAR1)
-                {
-                    Name (_HID, EisaId ("PNP0501"))
-                    Name (_UID, 0x01)
-                    Method (_STA, 0, NotSerialized)
-                    {
-                        If(LEqual(\_SB.UAR1, 0)) {
-                            Return(0x00)
-                        } Else {
-                            Return(0x0F)
-                        }
-                    }
-
-                    Name (_CRS, ResourceTemplate()
-                    {
-                        IO (Decode16, 0x03F8, 0x03F8, 8, 8)
-                        IRQNoFlags () {4}
-                    })
-                }
-
-                Device (UAR2)
-                {
-                    Name (_HID, EisaId ("PNP0501"))
-                    Name (_UID, 0x02)
-                    Method (_STA, 0, NotSerialized)
-                    {
-                        If(LEqual(\_SB.UAR2, 0)) {
-                            Return(0x00)
-                        } Else {
-                            Return(0x0F)
-                        }
-                    }
-
-                    Name (_CRS, ResourceTemplate()
-                    {
-                        IO (Decode16, 0x02F8, 0x02F8, 8, 8)
-                        IRQNoFlags () {3}
-                    })
-                }
-
-                Device (LTP1)
-                {
-                    Name (_HID, EisaId ("PNP0400"))
-                    Name (_UID, 0x02)
-                    Method (_STA, 0, NotSerialized)
-                    {
-                        If(LEqual(\_SB.LTP1, 0)) {
-                            Return(0x00)
-                        } Else {
-                            Return(0x0F)
-                        }
-                    }
-
-                    Name (_CRS, ResourceTemplate()
-                    {
-                        IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
-                        IRQNoFlags () {7}
-                    })
-                }
-
-                Device(VGID) {
-                    Name(_HID, EisaId ("XEN0000"))
-                    Name(_UID, 0x00)
-                    Name(_CID, "VM_Gen_Counter")
-                    Name(_DDN, "VM_Gen_Counter")
-                    Method(_STA, 0, NotSerialized)
-                    {
-                        If(LEqual(\_SB.VGIA, 0x00000000)) {
-                            Return(0x00)
-                        } Else {
-                            Return(0x0F)
-                        }
-                    }
-                    Name(PKG, Package ()
-                    {
-                        0x00000000,
-                        0x00000000
-                    })
-                    Method(ADDR, 0, NotSerialized)
-                    {
-                        Store(\_SB.VGIA, Index(PKG, 0))
-                        Return(PKG)
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/tools/firmware/hvmloader/acpi/gpl/COPYING b/tools/firmware/hvmloader/acpi/gpl/COPYING
new file mode 100644
index 0000000..8dfdf61
--- /dev/null
+++ b/tools/firmware/hvmloader/acpi/gpl/COPYING
@@ -0,0 +1,5 @@
+Unlike files in the directory above that are licensed under GNU Lesser
+General Public License version 2.1, files here are licensed under GNU
+General Public License version 2.
+
+A copy of this license can be obtained at <http://www.gnu.org/licenses/>
\ No newline at end of file
diff --git a/tools/firmware/hvmloader/acpi/gpl/dsdt.asl b/tools/firmware/hvmloader/acpi/gpl/dsdt.asl
new file mode 100644
index 0000000..7c5cc14
--- /dev/null
+++ b/tools/firmware/hvmloader/acpi/gpl/dsdt.asl
@@ -0,0 +1,846 @@
+/******************************************************************************
+ * DSDT for Xen with Qemu device model
+ *
+ * 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/>.
+ */
+
+DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
+{
+    Name (\PMBS, 0x0C00)
+    Name (\PMLN, 0x08)
+    Name (\IOB1, 0x00)
+    Name (\IOL1, 0x00)
+    Name (\APCB, 0xFEC00000)
+    Name (\APCL, 0x00010000)
+    Name (\PUID, 0x00)
+
+    /* _S3 and _S4 are in separate SSDTs */
+    Name (\_S5, Package (0x04)
+    {
+        0x00,  /* PM1a_CNT.SLP_TYP */
+        0x00,  /* PM1b_CNT.SLP_TYP */
+        0x00,  /* reserved */
+        0x00   /* reserved */
+    })
+
+    Name(PICD, 0)
+    Method(_PIC, 1)
+    {
+        Store(Arg0, PICD) 
+    }
+
+    Scope (\_SB)
+    {
+
+        /* Fix HCT test for 0x400 pci memory:
+         * - need to report low 640 MB mem as motherboard resource
+         */
+       Device(MEM0)
+       {
+           Name(_HID, EISAID("PNP0C02"))
+           Name(_CRS, ResourceTemplate() {
+               QWordMemory(
+                    ResourceConsumer, PosDecode, MinFixed,
+                    MaxFixed, Cacheable, ReadWrite,
+                    0x00000000,
+                    0x00000000,
+                    0x0009ffff,
+                    0x00000000,
+                    0x000a0000)
+           })
+       }
+
+       Device (PCI0)
+       {
+           Name (_HID, EisaId ("PNP0A03"))
+           Name (_UID, 0x00)
+           Name (_ADR, 0x00)
+           Name (_BBN, 0x00)
+
+           /* Make cirrues VGA S3 suspend/resume work in Windows XP/2003 */
+           Device (VGA)
+           {
+               Name (_ADR, 0x00020000)
+
+               Method (_S1D, 0, NotSerialized)
+               {
+                   Return (0x00)
+               }
+               Method (_S2D, 0, NotSerialized)
+               {
+                   Return (0x00)
+               }
+               Method (_S3D, 0, NotSerialized)
+               {
+                   Return (0x00)
+               }
+           }
+
+           Method (_CRS, 0, NotSerialized)
+           {
+               Store (ResourceTemplate ()
+               {
+                   /* bus number is from 0 - 255*/
+                   WordBusNumber(
+                        ResourceProducer, MinFixed, MaxFixed, SubDecode,
+                        0x0000,
+                        0x0000,
+                        0x00FF,
+                        0x0000,
+                        0x0100)
+                    IO (Decode16, 0x0CF8, 0x0CF8, 0x01, 0x08)
+                    WordIO(
+                        ResourceProducer, MinFixed, MaxFixed, PosDecode,
+                        EntireRange,
+                        0x0000,
+                        0x0000,
+                        0x0CF7,
+                        0x0000,
+                        0x0CF8)
+                    WordIO(
+                        ResourceProducer, MinFixed, MaxFixed, PosDecode,
+                        EntireRange,
+                        0x0000,
+                        0x0D00,
+                        0xFFFF,
+                        0x0000,
+                        0xF300)
+
+                    /* reserve memory for pci devices */
+                    DWordMemory(
+                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
+                        WriteCombining, ReadWrite,
+                        0x00000000,
+                        0x000A0000,
+                        0x000BFFFF,
+                        0x00000000,
+                        0x00020000)
+
+                    DWordMemory(
+                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
+                        NonCacheable, ReadWrite,
+                        0x00000000,
+                        0xF0000000,
+                        0xF4FFFFFF,
+                        0x00000000,
+                        0x05000000,
+                        ,, _Y01)
+
+                    QWordMemory (
+                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
+                        NonCacheable, ReadWrite,
+                        0x0000000000000000,
+                        0x0000000FFFFFFFF0,
+                        0x0000000FFFFFFFFF,
+                        0x0000000000000000,
+                        0x0000000000000010,
+                        ,, _Y02)
+
+                }, Local1)
+
+                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._MIN, MMIN)
+                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._MAX, MMAX)
+                CreateDWordField(Local1, \_SB.PCI0._CRS._Y01._LEN, MLEN)
+
+                Store(\_SB.PMIN, MMIN)
+                Store(\_SB.PLEN, MLEN)
+                Add(MMIN, MLEN, MMAX)
+                Subtract(MMAX, One, MMAX)
+
+                /*
+                 * WinXP / Win2K3 blue-screen for operations on 64-bit values.
+                 * Therefore we need to split the 64-bit calculations needed
+                 * here, but different iasl versions evaluate name references
+                 * to integers differently:
+                 * Year (approximate)          2006    2008    2012
+                 * \_SB.PCI0._CRS._Y02         zero   valid   valid
+                 * \_SB.PCI0._CRS._Y02._MIN   valid   valid    huge
+                 */
+                If(LEqual(Zero, \_SB.PCI0._CRS._Y02)) {
+                    Subtract(\_SB.PCI0._CRS._Y02._MIN, 14, Local0)
+                } Else {
+                    Store(\_SB.PCI0._CRS._Y02, Local0)
+                }
+                CreateDWordField(Local1, Add(Local0, 14), MINL)
+                CreateDWordField(Local1, Add(Local0, 18), MINH)
+                CreateDWordField(Local1, Add(Local0, 22), MAXL)
+                CreateDWordField(Local1, Add(Local0, 26), MAXH)
+                CreateDWordField(Local1, Add(Local0, 38), LENL)
+                CreateDWordField(Local1, Add(Local0, 42), LENH)
+
+                Store(\_SB.LMIN, MINL)
+                Store(\_SB.HMIN, MINH)
+                Store(\_SB.LLEN, LENL)
+                Store(\_SB.HLEN, LENH)
+                Add(MINL, LENL, MAXL)
+                Add(MINH, LENH, MAXH)
+                If(LLess(MAXL, MINL)) {
+                    Add(MAXH, One, MAXH)
+                }
+                If(LOr(MINH, LENL)) {
+                    If(LEqual(MAXL, 0)) {
+                        Subtract(MAXH, One, MAXH)
+                    }
+                    Subtract(MAXL, One, MAXL)
+                }
+
+                Return (Local1)
+            }
+
+            Device(HPET) {
+                Name(_HID,  EISAID("PNP0103"))
+                Name(_UID, 0)
+                Method (_STA, 0, NotSerialized) {
+                    If(LEqual(\_SB.HPET, 0)) {
+                        Return(0x00)
+                    } Else {
+                        Return(0x0F)
+                    }
+                }
+                Name(_CRS, ResourceTemplate() {
+                    DWordMemory(
+                        ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                        NonCacheable, ReadWrite,
+                        0x00000000,
+                        0xFED00000,
+                        0xFED003FF,
+                        0x00000000,
+                        0x00000400 /* 1K memory: FED00000 - FED003FF */
+                    )
+                })
+            }
+
+            Device (ISA)
+            {
+                Name (_ADR, 0x00010000) /* device 1, fn 0 */
+
+                OperationRegion(PIRQ, PCI_Config, 0x60, 0x4)
+                Scope(\) {
+                    Field (\_SB.PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
+                        PIRA, 8,
+                        PIRB, 8,
+                        PIRC, 8,
+                        PIRD, 8
+                    }
+                }
+                Device (SYSR)
+                {
+                    Name (_HID, EisaId ("PNP0C02"))
+                    Name (_UID, 0x01)
+                    Name (CRS, ResourceTemplate ()
+                    {
+                        /* TODO: list hidden resources */
+                        IO (Decode16, 0x0010, 0x0010, 0x00, 0x10)
+                        IO (Decode16, 0x0022, 0x0022, 0x00, 0x0C)
+                        IO (Decode16, 0x0030, 0x0030, 0x00, 0x10)
+                        IO (Decode16, 0x0044, 0x0044, 0x00, 0x1C)
+                        IO (Decode16, 0x0062, 0x0062, 0x00, 0x02)
+                        IO (Decode16, 0x0065, 0x0065, 0x00, 0x0B)
+                        IO (Decode16, 0x0072, 0x0072, 0x00, 0x0E)
+                        IO (Decode16, 0x0080, 0x0080, 0x00, 0x01)
+                        IO (Decode16, 0x0084, 0x0084, 0x00, 0x03)
+                        IO (Decode16, 0x0088, 0x0088, 0x00, 0x01)
+                        IO (Decode16, 0x008C, 0x008C, 0x00, 0x03)
+                        IO (Decode16, 0x0090, 0x0090, 0x00, 0x10)
+                        IO (Decode16, 0x00A2, 0x00A2, 0x00, 0x1C)
+                        IO (Decode16, 0x00E0, 0x00E0, 0x00, 0x10)
+                        IO (Decode16, 0x08A0, 0x08A0, 0x00, 0x04)
+                        IO (Decode16, 0x0CC0, 0x0CC0, 0x00, 0x10)
+                        IO (Decode16, 0x04D0, 0x04D0, 0x00, 0x02)
+                    })
+                    Method (_CRS, 0, NotSerialized)
+                    {
+                        Return (CRS)
+                    }
+                }
+
+                Device (PIC)
+                {
+                    Name (_HID, EisaId ("PNP0000"))
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IO (Decode16, 0x0020, 0x0020, 0x01, 0x02)
+                        IO (Decode16, 0x00A0, 0x00A0, 0x01, 0x02)
+                        IRQNoFlags () {2}
+                    })
+                }
+
+                Device (DMA0)
+                {
+                    Name (_HID, EisaId ("PNP0200"))
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        DMA (Compatibility, BusMaster, Transfer8) {4}
+                        IO (Decode16, 0x0000, 0x0000, 0x00, 0x10)
+                        IO (Decode16, 0x0081, 0x0081, 0x00, 0x03)
+                        IO (Decode16, 0x0087, 0x0087, 0x00, 0x01)
+                        IO (Decode16, 0x0089, 0x0089, 0x00, 0x03)
+                        IO (Decode16, 0x008F, 0x008F, 0x00, 0x01)
+                        IO (Decode16, 0x00C0, 0x00C0, 0x00, 0x20)
+                        IO (Decode16, 0x0480, 0x0480, 0x00, 0x10)
+                    })
+                }
+
+                Device (TMR)
+                {
+                    Name (_HID, EisaId ("PNP0100"))
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IO (Decode16, 0x0040, 0x0040, 0x00, 0x04)
+                        IRQNoFlags () {0}
+                    })
+                }
+
+                Device (RTC)
+                {
+                    Name (_HID, EisaId ("PNP0B00"))
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IO (Decode16, 0x0070, 0x0070, 0x00, 0x02)
+                        IRQNoFlags () {8}
+                    })
+                }
+
+                Device (SPKR)
+                {
+                    Name (_HID, EisaId ("PNP0800"))
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IO (Decode16, 0x0061, 0x0061, 0x00, 0x01)
+                    })
+                }
+
+                Device (PS2M)
+                {
+                    Name (_HID, EisaId ("PNP0F13"))
+                    Name (_CID, 0x130FD041)
+                    Method (_STA, 0, NotSerialized)
+                    {
+                        Return (0x0F)
+                    }
+
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IRQNoFlags () {12}
+                    })
+                }
+
+                Device (PS2K)
+                {
+                    Name (_HID, EisaId ("PNP0303"))
+                    Name (_CID, 0x0B03D041)
+                    Method (_STA, 0, NotSerialized)
+                    {
+                        Return (0x0F)
+                    }
+
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IO (Decode16, 0x0060, 0x0060, 0x00, 0x01)
+                        IO (Decode16, 0x0064, 0x0064, 0x00, 0x01)
+                        IRQNoFlags () {1}
+                    })
+                }
+
+                Device (FDC0)
+                {
+                    Name (_HID, EisaId ("PNP0700"))
+                    Method (_STA, 0, NotSerialized)
+                    {
+                          Return (0x0F)
+                    }
+
+                    Name (_CRS, ResourceTemplate ()
+                    {
+                        IO (Decode16, 0x03F0, 0x03F0, 0x01, 0x06)
+                        IO (Decode16, 0x03F7, 0x03F7, 0x01, 0x01)
+                        IRQNoFlags () {6}
+                        DMA (Compatibility, NotBusMaster, Transfer8) {2}
+                    })
+                }
+
+                Device (UAR1)
+                {
+                    Name (_HID, EisaId ("PNP0501"))
+                    Name (_UID, 0x01)
+                    Method (_STA, 0, NotSerialized)
+                    {
+                        If(LEqual(\_SB.UAR1, 0)) {
+                            Return(0x00)
+                        } Else {
+                            Return(0x0F)
+                        }
+                    }
+
+                    Name (_CRS, ResourceTemplate()
+                    {
+                        IO (Decode16, 0x03F8, 0x03F8, 8, 8)
+                        IRQNoFlags () {4}
+                    })
+                }
+
+                Device (UAR2)
+                {
+                    Name (_HID, EisaId ("PNP0501"))
+                    Name (_UID, 0x02)
+                    Method (_STA, 0, NotSerialized)
+                    {
+                        If(LEqual(\_SB.UAR2, 0)) {
+                            Return(0x00)
+                        } Else {
+                            Return(0x0F)
+                        }
+                    }
+
+                    Name (_CRS, ResourceTemplate()
+                    {
+                        IO (Decode16, 0x02F8, 0x02F8, 8, 8)
+                        IRQNoFlags () {3}
+                    })
+                }
+
+                Device (LTP1)
+                {
+                    Name (_HID, EisaId ("PNP0400"))
+                    Name (_UID, 0x02)
+                    Method (_STA, 0, NotSerialized)
+                    {
+                        If(LEqual(\_SB.LTP1, 0)) {
+                            Return(0x00)
+                        } Else {
+                            Return(0x0F)
+                        }
+                    }
+
+                    Name (_CRS, ResourceTemplate()
+                    {
+                        IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
+                        IRQNoFlags () {7}
+                    })
+                }
+
+                Device(VGID) {
+                    Name(_HID, EisaId ("XEN0000"))
+                    Name(_UID, 0x00)
+                    Name(_CID, "VM_Gen_Counter")
+                    Name(_DDN, "VM_Gen_Counter")
+                    Method(_STA, 0, NotSerialized)
+                    {
+                        If(LEqual(\_SB.VGIA, 0x00000000)) {
+                            Return(0x00)
+                        } Else {
+                            Return(0x0F)
+                        }
+                    }
+                    Name(PKG, Package ()
+                    {
+                        0x00000000,
+                        0x00000000
+                    })
+                    Method(ADDR, 0, NotSerialized)
+                    {
+                        Store(\_SB.VGIA, Index(PKG, 0))
+                        Return(PKG)
+                    }
+                }
+            }
+        }
+    }
+
+    Scope ( \_SB.PCI0 )
+    {
+        Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
+        Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )
+        CreateWordField ( BUFB, 0x01, IRQV )
+        Device ( LNKA ) {
+            Name ( _HID,  EISAID("PNP0C0F") )
+            Name ( _UID, 1 )
+            Method ( _STA, 0 ) {
+                If ( And(PIRA, 0x80) ) {
+                    Return ( 0x09 )
+                }
+                Else {
+                    Return ( 0x0B )
+                }
+            }
+            Method ( _PRS ) {
+                Return ( BUFA )
+            }
+            Method ( _DIS ) {
+                Or ( PIRA, 0x80, PIRA )
+            }
+            Method ( _CRS ) {
+                And ( PIRA, 0x0f, Local0 )
+                ShiftLeft ( 0x1, Local0, IRQV )
+                Return ( BUFB )
+            }
+            Method ( _SRS, 1 ) {
+                CreateWordField ( ARG0, 0x01, IRQ1 )
+                FindSetRightBit ( IRQ1, Local0 )
+                Decrement ( Local0 )
+                Store ( Local0, PIRA )
+            }
+        }
+        Device ( LNKB ) {
+            Name ( _HID,  EISAID("PNP0C0F") )
+            Name ( _UID, 2 )
+            Method ( _STA, 0 ) {
+                If ( And(PIRB, 0x80) ) {
+                    Return ( 0x09 )
+                }
+                Else {
+                    Return ( 0x0B )
+                }
+            }
+            Method ( _PRS ) {
+                Return ( BUFA )
+            }
+            Method ( _DIS ) {
+                Or ( PIRB, 0x80, PIRB )
+            }
+            Method ( _CRS ) {
+                And ( PIRB, 0x0f, Local0 )
+                ShiftLeft ( 0x1, Local0, IRQV )
+                Return ( BUFB )
+            }
+            Method ( _SRS, 1 ) {
+                CreateWordField ( ARG0, 0x01, IRQ1 )
+                FindSetRightBit ( IRQ1, Local0 )
+                Decrement ( Local0 )
+                Store ( Local0, PIRB )
+            }
+        }
+        Device ( LNKC ) {
+            Name ( _HID,  EISAID("PNP0C0F") )
+            Name ( _UID, 3 )
+            Method ( _STA, 0 ) {
+                If ( And(PIRC, 0x80) ) {
+                    Return ( 0x09 )
+                }
+                Else {
+                    Return ( 0x0B )
+                }
+            }
+            Method ( _PRS ) {
+                Return ( BUFA )
+            }
+            Method ( _DIS ) {
+                Or ( PIRC, 0x80, PIRC )
+            }
+            Method ( _CRS ) {
+                And ( PIRC, 0x0f, Local0 )
+                ShiftLeft ( 0x1, Local0, IRQV )
+                Return ( BUFB )
+            }
+            Method ( _SRS, 1 ) {
+                CreateWordField ( ARG0, 0x01, IRQ1 )
+                FindSetRightBit ( IRQ1, Local0 )
+                Decrement ( Local0 )
+                Store ( Local0, PIRC )
+            }
+        }
+        Device ( LNKD ) {
+            Name ( _HID,  EISAID("PNP0C0F") )
+            Name ( _UID, 4 )
+            Method ( _STA, 0 ) {
+                If ( And(PIRD, 0x80) ) {
+                    Return ( 0x09 )
+                }
+                Else {
+                    Return ( 0x0B )
+                }
+            }
+            Method ( _PRS ) {
+                Return ( BUFA )
+            }
+            Method ( _DIS ) {
+                Or ( PIRD, 0x80, PIRD )
+            }
+            Method ( _CRS ) {
+                And ( PIRD, 0x0f, Local0 )
+                ShiftLeft ( 0x1, Local0, IRQV )
+                Return ( BUFB )
+            }
+            Method ( _SRS, 1 ) {
+                CreateWordField ( ARG0, 0x01, IRQ1 )
+                FindSetRightBit ( IRQ1, Local0 )
+                Decrement ( Local0 )
+                Store ( Local0, PIRD )
+            }
+        }
+        Method ( _PRT, 0 ) {
+            If ( PICD ) {
+                Return ( PRTA )
+            }
+            Return ( PRTP )
+        }
+
+        Name(PRTP, Package()
+        {
+                Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x0002ffff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x0002ffff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x0002ffff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x0003ffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x0003ffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x0003ffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x0003ffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x0004ffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x0004ffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x0004ffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x0004ffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x0005ffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x0005ffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x0005ffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x0005ffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x0006ffff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x0006ffff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x0006ffff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x0006ffff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x0007ffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x0007ffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x0007ffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x0007ffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x0008ffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x0008ffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x0008ffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x0008ffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x0009ffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x0009ffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x0009ffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x0009ffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x000affff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x000affff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x000affff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x000affff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x000bffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x000bffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x000bffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x000bffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x000cffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x000cffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x000cffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x000cffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x000dffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x000dffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x000dffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x000dffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x000effff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x000effff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x000effff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x000effff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x000fffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x000fffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x000fffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x000fffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x0010ffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x0010ffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x0010ffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x0010ffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x0011ffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x0011ffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x0011ffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x0011ffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x0012ffff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x0012ffff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x0012ffff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x0012ffff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x0013ffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x0013ffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x0013ffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x0013ffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x0014ffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x0014ffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x0014ffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x0014ffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x0015ffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x0015ffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x0015ffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x0015ffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x0016ffff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x0016ffff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x0016ffff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x0016ffff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x0017ffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x0017ffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x0017ffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x0017ffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x0018ffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x0018ffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x0018ffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x0018ffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x0019ffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x0019ffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x0019ffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x0019ffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x001affff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x001affff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x001affff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x001affff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x001bffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x001bffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x001bffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x001bffff, 3, \_SB.PCI0.LNKC, 0},
+                Package(){0x001cffff, 0, \_SB.PCI0.LNKA, 0},
+                Package(){0x001cffff, 1, \_SB.PCI0.LNKB, 0},
+                Package(){0x001cffff, 2, \_SB.PCI0.LNKC, 0},
+                Package(){0x001cffff, 3, \_SB.PCI0.LNKD, 0},
+                Package(){0x001dffff, 0, \_SB.PCI0.LNKB, 0},
+                Package(){0x001dffff, 1, \_SB.PCI0.LNKC, 0},
+                Package(){0x001dffff, 2, \_SB.PCI0.LNKD, 0},
+                Package(){0x001dffff, 3, \_SB.PCI0.LNKA, 0},
+                Package(){0x001effff, 0, \_SB.PCI0.LNKC, 0},
+                Package(){0x001effff, 1, \_SB.PCI0.LNKD, 0},
+                Package(){0x001effff, 2, \_SB.PCI0.LNKA, 0},
+                Package(){0x001effff, 3, \_SB.PCI0.LNKB, 0},
+                Package(){0x001fffff, 0, \_SB.PCI0.LNKD, 0},
+                Package(){0x001fffff, 1, \_SB.PCI0.LNKA, 0},
+                Package(){0x001fffff, 2, \_SB.PCI0.LNKB, 0},
+                Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0},
+        })
+
+        Name(PRTA, Package()
+        {
+                Package(){0x0001ffff, 0, 0, 20},
+                Package(){0x0001ffff, 1, 0, 21},
+                Package(){0x0001ffff, 2, 0, 22},
+                Package(){0x0001ffff, 3, 0, 23},
+                Package(){0x0002ffff, 0, 0, 24},
+                Package(){0x0002ffff, 1, 0, 25},
+                Package(){0x0002ffff, 2, 0, 26},
+                Package(){0x0002ffff, 3, 0, 27},
+                Package(){0x0003ffff, 0, 0, 28},
+                Package(){0x0003ffff, 1, 0, 29},
+                Package(){0x0003ffff, 2, 0, 30},
+                Package(){0x0003ffff, 3, 0, 31},
+                Package(){0x0004ffff, 0, 0, 32},
+                Package(){0x0004ffff, 1, 0, 33},
+                Package(){0x0004ffff, 2, 0, 34},
+                Package(){0x0004ffff, 3, 0, 35},
+                Package(){0x0005ffff, 0, 0, 36},
+                Package(){0x0005ffff, 1, 0, 37},
+                Package(){0x0005ffff, 2, 0, 38},
+                Package(){0x0005ffff, 3, 0, 39},
+                Package(){0x0006ffff, 0, 0, 40},
+                Package(){0x0006ffff, 1, 0, 41},
+                Package(){0x0006ffff, 2, 0, 42},
+                Package(){0x0006ffff, 3, 0, 43},
+                Package(){0x0007ffff, 0, 0, 44},
+                Package(){0x0007ffff, 1, 0, 45},
+                Package(){0x0007ffff, 2, 0, 46},
+                Package(){0x0007ffff, 3, 0, 47},
+                Package(){0x0008ffff, 0, 0, 17},
+                Package(){0x0008ffff, 1, 0, 18},
+                Package(){0x0008ffff, 2, 0, 19},
+                Package(){0x0008ffff, 3, 0, 20},
+                Package(){0x0009ffff, 0, 0, 21},
+                Package(){0x0009ffff, 1, 0, 22},
+                Package(){0x0009ffff, 2, 0, 23},
+                Package(){0x0009ffff, 3, 0, 24},
+                Package(){0x000affff, 0, 0, 25},
+                Package(){0x000affff, 1, 0, 26},
+                Package(){0x000affff, 2, 0, 27},
+                Package(){0x000affff, 3, 0, 28},
+                Package(){0x000bffff, 0, 0, 29},
+                Package(){0x000bffff, 1, 0, 30},
+                Package(){0x000bffff, 2, 0, 31},
+                Package(){0x000bffff, 3, 0, 32},
+                Package(){0x000cffff, 0, 0, 33},
+                Package(){0x000cffff, 1, 0, 34},
+                Package(){0x000cffff, 2, 0, 35},
+                Package(){0x000cffff, 3, 0, 36},
+                Package(){0x000dffff, 0, 0, 37},
+                Package(){0x000dffff, 1, 0, 38},
+                Package(){0x000dffff, 2, 0, 39},
+                Package(){0x000dffff, 3, 0, 40},
+                Package(){0x000effff, 0, 0, 41},
+                Package(){0x000effff, 1, 0, 42},
+                Package(){0x000effff, 2, 0, 43},
+                Package(){0x000effff, 3, 0, 44},
+                Package(){0x000fffff, 0, 0, 45},
+                Package(){0x000fffff, 1, 0, 46},
+                Package(){0x000fffff, 2, 0, 47},
+                Package(){0x000fffff, 3, 0, 16},
+                Package(){0x0010ffff, 0, 0, 18},
+                Package(){0x0010ffff, 1, 0, 19},
+                Package(){0x0010ffff, 2, 0, 20},
+                Package(){0x0010ffff, 3, 0, 21},
+                Package(){0x0011ffff, 0, 0, 22},
+                Package(){0x0011ffff, 1, 0, 23},
+                Package(){0x0011ffff, 2, 0, 24},
+                Package(){0x0011ffff, 3, 0, 25},
+                Package(){0x0012ffff, 0, 0, 26},
+                Package(){0x0012ffff, 1, 0, 27},
+                Package(){0x0012ffff, 2, 0, 28},
+                Package(){0x0012ffff, 3, 0, 29},
+                Package(){0x0013ffff, 0, 0, 30},
+                Package(){0x0013ffff, 1, 0, 31},
+                Package(){0x0013ffff, 2, 0, 32},
+                Package(){0x0013ffff, 3, 0, 33},
+                Package(){0x0014ffff, 0, 0, 34},
+                Package(){0x0014ffff, 1, 0, 35},
+                Package(){0x0014ffff, 2, 0, 36},
+                Package(){0x0014ffff, 3, 0, 37},
+                Package(){0x0015ffff, 0, 0, 38},
+                Package(){0x0015ffff, 1, 0, 39},
+                Package(){0x0015ffff, 2, 0, 40},
+                Package(){0x0015ffff, 3, 0, 41},
+                Package(){0x0016ffff, 0, 0, 42},
+                Package(){0x0016ffff, 1, 0, 43},
+                Package(){0x0016ffff, 2, 0, 44},
+                Package(){0x0016ffff, 3, 0, 45},
+                Package(){0x0017ffff, 0, 0, 46},
+                Package(){0x0017ffff, 1, 0, 47},
+                Package(){0x0017ffff, 2, 0, 16},
+                Package(){0x0017ffff, 3, 0, 17},
+                Package(){0x0018ffff, 0, 0, 19},
+                Package(){0x0018ffff, 1, 0, 20},
+                Package(){0x0018ffff, 2, 0, 21},
+                Package(){0x0018ffff, 3, 0, 22},
+                Package(){0x0019ffff, 0, 0, 23},
+                Package(){0x0019ffff, 1, 0, 24},
+                Package(){0x0019ffff, 2, 0, 25},
+                Package(){0x0019ffff, 3, 0, 26},
+                Package(){0x001affff, 0, 0, 27},
+                Package(){0x001affff, 1, 0, 28},
+                Package(){0x001affff, 2, 0, 29},
+                Package(){0x001affff, 3, 0, 30},
+                Package(){0x001bffff, 0, 0, 31},
+                Package(){0x001bffff, 1, 0, 32},
+                Package(){0x001bffff, 2, 0, 33},
+                Package(){0x001bffff, 3, 0, 34},
+                Package(){0x001cffff, 0, 0, 35},
+                Package(){0x001cffff, 1, 0, 36},
+                Package(){0x001cffff, 2, 0, 37},
+                Package(){0x001cffff, 3, 0, 38},
+                Package(){0x001dffff, 0, 0, 39},
+                Package(){0x001dffff, 1, 0, 40},
+                Package(){0x001dffff, 2, 0, 41},
+                Package(){0x001dffff, 3, 0, 42},
+                Package(){0x001effff, 0, 0, 43},
+                Package(){0x001effff, 1, 0, 44},
+                Package(){0x001effff, 2, 0, 45},
+                Package(){0x001effff, 3, 0, 46},
+                Package(){0x001fffff, 0, 0, 47},
+                Package(){0x001fffff, 1, 0, 16},
+                Package(){0x001fffff, 2, 0, 17},
+                Package(){0x001fffff, 3, 0, 18},
+        })
+    }
+}
diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c b/tools/firmware/hvmloader/acpi/mk_dsdt.c
index b2ade89..7656b5d 100644
--- a/tools/firmware/hvmloader/acpi/mk_dsdt.c
+++ b/tools/firmware/hvmloader/acpi/mk_dsdt.c
@@ -91,7 +91,7 @@ static struct option options[] = {
 
 int main(int argc, char **argv)
 {
-    unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
+    unsigned int slot, cpu, max_cpus = HVM_MAX_VCPUS;
     dm_version dm_version = QEMU_XEN_TRADITIONAL;
 
     for ( ; ; )
@@ -273,72 +273,6 @@ int main(int argc, char **argv)
         }
     } pop_block();
 
-    /*** PCI-ISA link definitions ***/
-    /* BUFA: List of ISA IRQs available for linking to PCI INTx. */
-    stmt("Name", "BUFA, ResourceTemplate() { "
-         "IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } }");
-    /* BUFB: IRQ descriptor for returning from link-device _CRS methods. */
-    stmt("Name", "BUFB, Buffer() { "
-         "0x23, 0x00, 0x00, 0x18, " /* IRQ descriptor */
-         "0x79, 0 }");              /* End tag, null checksum */
-    stmt("CreateWordField", "BUFB, 0x01, IRQV");
-    /* Create four PCI-ISA link devices: LNKA, LNKB, LNKC, LNKD. */
-    for ( link = 0; link < 4; link++ )
-    {
-        push_block("Device", "LNK%c", 'A'+link);
-        stmt("Name", "_HID,  EISAID(\"PNP0C0F\")");  /* PCI interrupt link */
-        stmt("Name", "_UID, %u", link+1);
-        push_block("Method", "_STA, 0");
-        push_block("If", "And(PIR%c, 0x80)", 'A'+link);
-        stmt("Return", "0x09");
-        pop_block();
-        push_block("Else", NULL);
-        stmt("Return", "0x0B");
-        pop_block();
-        pop_block();
-        push_block("Method", "_PRS");
-        stmt("Return", "BUFA");
-        pop_block();
-        push_block("Method", "_DIS");
-        stmt("Or", "PIR%c, 0x80, PIR%c", 'A'+link, 'A'+link);
-        pop_block();
-        push_block("Method", "_CRS");
-        stmt("And", "PIR%c, 0x0f, Local0", 'A'+link);
-        stmt("ShiftLeft", "0x1, Local0, IRQV");
-        stmt("Return", "BUFB");
-        pop_block();
-        push_block("Method", "_SRS, 1");
-        stmt("CreateWordField", "ARG0, 0x01, IRQ1");
-        stmt("FindSetRightBit", "IRQ1, Local0");
-        stmt("Decrement", "Local0");
-        stmt("Store", "Local0, PIR%c", 'A'+link);
-        pop_block();
-        pop_block();
-    }
-
-    /*** PCI interrupt routing definitions***/
-    /* _PRT: Method to return routing table. */
-    push_block("Method", "_PRT, 0");
-    push_block("If", "PICD");
-    stmt("Return", "PRTA");
-    pop_block();
-    stmt("Return", "PRTP");
-    pop_block();
-    /* PRTP: PIC routing table (via ISA links). */
-    printf("Name(PRTP, Package() {\n");
-    for ( dev = 1; dev < 32; dev++ )
-        for ( intx = 0; intx < 4; intx++ ) /* INTA-D */
-            printf("Package(){0x%04xffff, %u, \\_SB.PCI0.LNK%c, 0},\n",
-                   dev, intx, 'A'+((dev+intx)&3));
-    printf("})\n");
-    /* PRTA: APIC routing table (via non-legacy IOAPIC GSIs). */
-    printf("Name(PRTA, Package() {\n");
-    for ( dev = 1; dev < 32; dev++ )
-        for ( intx = 0; intx < 4; intx++ ) /* INTA-D */
-            printf("Package(){0x%04xffff, %u, 0, %u},\n",
-                   dev, intx, ((dev*4+dev/8+intx)&31)+16);
-    printf("})\n");
-
     /*
      * Each PCI hotplug slot needs at least two methods to handle
      * the ACPI event:
-- 
1.8.3.1


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

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

* [PATCH v4 03/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-20 10:17   ` Lars Kurth
  2016-09-20  0:19 ` [PATCH v4 04/21] acpi/hvmloader: Collect processor and NUMA info in hvmloader Boris Ostrovsky
                   ` (17 subsequent siblings)
  20 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Lars Kurth, Kevin Tian, wei.liu2, Kouya Shimura, andrew.cooper3,
	ian.jackson, julien.grall, Simon Horman, keke, jbeulich,
	zhaoshenglong, Stefan Berger, Boris Ostrovsky, Keir Fraser,
	Daniel Kiper, roger.pau

ACPI builder is currently distributed under GPLv2 license.

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

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

(dsdt.asl remains GPLv2 as we might need permission from Lenovo
due to commit 801d469ad ("[HVM] ACPI support patch 3 of 4: ACPI
_PRT table."))

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

Changes in v4:
* Dropped dsdt.asl until Lenovo ACK is received (note that mk_dsdt.c *is* made LGPL)

 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/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 ++++++++----------
 9 files changed, 64 insertions(+), 72 deletions(-)

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


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

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

* [PATCH v4 04/21] acpi/hvmloader: Collect processor and NUMA info in hvmloader
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (2 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 03/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-21 10:42   ` Jan Beulich
  2016-09-20  0:19 ` [PATCH v4 05/21] acpi/hvmloader: Set TIS header address " Boris Ostrovsky
                   ` (16 subsequent siblings)
  20 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

No need for ACPI code to rely on hvm_info variable.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* Constified mode things (struct acpi_config's hvminfo, test_bit's argument)
* Removed xen/memory.h from libacpi.h


 tools/firmware/hvmloader/acpi/build.c   | 52 ++++++++++++++++++---------------
 tools/firmware/hvmloader/acpi/libacpi.h | 11 +++++++
 tools/firmware/hvmloader/util.c         |  9 ++++++
 tools/firmware/hvmloader/util.h         |  2 +-
 4 files changed, 49 insertions(+), 25 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index de56f1f..68eb7c4 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -24,6 +24,7 @@
 #include "../vnuma.h"
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
+#include <xen/memory.h>
 
 #define ACPI_MAX_SECONDARY_TABLES 16
 
@@ -70,18 +71,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;
+    const 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 +137,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 +147,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 +198,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 +207,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 +225,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 +256,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 +278,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 +339,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 +423,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 +519,7 @@ void acpi_build_tables(struct acpi_config *config)
      * The latter is required for Windows 2000, which experiences a BSOD of
      * KMODE_EXCEPTION_NOT_HANDLED if it sees more than 15 processor objects.
      */
-    if ( hvm_info->nr_vcpus <= 15 && config->dsdt_15cpu)
+    if ( config->hvminfo->nr_vcpus <= 15 && config->dsdt_15cpu)
     {
         dsdt = mem_alloc(config->dsdt_15cpu_len, 16);
         if (!dsdt) goto oom;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index 22fd5f6..d1e7042 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -28,6 +28,14 @@
 #define ACPI_HAS_SSDT_S3     (1<<5)
 #define ACPI_HAS_SSDT_S4     (1<<6)
 
+struct xen_vmemrange;
+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;
@@ -49,6 +57,9 @@ struct acpi_config {
         uint32_t length;
     } pt;
 
+    struct acpi_numa numa;
+    const struct hvm_info_table *hvminfo;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index b2d3421..f37b16e 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "hypercall.h"
 #include "ctype.h"
+#include "vnuma.h"
 #include "acpi/acpi2_0.h"
 #include "acpi/libacpi.h"
 #include <stdint.h>
@@ -918,6 +919,14 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
+    config->numa.nr_vmemranges = nr_vmemranges;
+    config->numa.nr_vnodes = nr_vnodes;
+    config->numa.vcpu_to_vnode = vcpu_to_vnode;
+    config->numa.vdistance = vdistance;
+    config->numa.vmemrange = vmemrange;
+
+    config->hvminfo = hvm_info;
+
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h
index 94292d6..e323778 100644
--- a/tools/firmware/hvmloader/util.h
+++ b/tools/firmware/hvmloader/util.h
@@ -47,7 +47,7 @@ void __bug(char *file, int line) __attribute__((noreturn));
 #define max_t(type,x,y) \
         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 
-static inline int test_bit(unsigned int b, void *p)
+static inline int test_bit(unsigned int b, const void *p)
 {
     return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
 }
-- 
1.8.3.1


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

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

* [PATCH v4 05/21] acpi/hvmloader: Set TIS header address in hvmloader
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (3 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 04/21] acpi/hvmloader: Collect processor and NUMA info in hvmloader Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 06/21] acpi/hvmloader: Make providing IOAPIC in MADT optional Boris Ostrovsky
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

Users other than hvmloader may provide TIS address as virtual.

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

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 68eb7c4..c984e5a 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -335,7 +335,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. */
@@ -388,10 +387,10 @@ static int construct_secondary_tables(unsigned long *table_ptrs,
     }
 
     /* TPM TCPA and SSDT. */
-    tis_hdr = (uint16_t *)0xFED40F00;
-    if ( (tis_hdr[0] == tis_signature[0]) &&
-         (tis_hdr[1] == tis_signature[1]) &&
-         (tis_hdr[2] == tis_signature[2]) )
+    if ( (config->table_flags & ACPI_HAS_TCPA) &&
+         (config->tis_hdr[0] == tis_signature[0]) &&
+         (config->tis_hdr[1] == tis_signature[1]) &&
+         (config->tis_hdr[2] == tis_signature[2]) )
     {
         ssdt = mem_alloc(sizeof(ssdt_tpm), 16);
         if (!ssdt) return -1;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index d1e7042..70cf26b 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -27,6 +27,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 xen_vmemrange;
 struct acpi_numa {
@@ -60,6 +61,8 @@ struct acpi_config {
     struct acpi_numa numa;
     const struct hvm_info_table *hvminfo;
 
+    const uint16_t *tis_hdr;
+
     /*
      * Address where acpi_info should be placed.
      * This must match the OperationRegion(BIOS, SystemMemory, ....)
diff --git a/tools/firmware/hvmloader/config.h b/tools/firmware/hvmloader/config.h
index a4429f4..6e00413 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -56,6 +56,8 @@ extern uint8_t ioapic_version;
 /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
 #define PCI_MEM_END         0xfc000000
 
+#define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
+
 extern unsigned long pci_mem_start, pci_mem_end;
 extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
 
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index f37b16e..8875675 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -919,6 +919,10 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_HAS_SSDT_S4;
 
+    config->table_flags |= ACPI_HAS_TCPA;
+
+    config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS;
+
     config->numa.nr_vmemranges = nr_vmemranges;
     config->numa.nr_vnodes = nr_vnodes;
     config->numa.vcpu_to_vnode = vcpu_to_vnode;
-- 
1.8.3.1


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

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

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

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

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


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

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

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

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

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


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

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

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

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes in v4:
* Added comment to acpi_mem_free()

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

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 537933b..1dd9987 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -71,7 +71,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;
@@ -86,7 +87,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));
@@ -166,11 +167,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));
@@ -189,11 +191,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));
@@ -204,7 +207,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;
@@ -216,7 +220,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;
 
@@ -262,7 +266,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;
@@ -270,7 +275,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;
 
@@ -294,7 +299,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)
 {
@@ -317,7 +323,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);
@@ -330,7 +336,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)
 {
@@ -346,7 +353,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;
     }
@@ -354,7 +361,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;
     }
@@ -362,7 +369,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;
@@ -370,7 +377,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;
@@ -378,7 +385,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;
@@ -388,7 +395,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;
@@ -402,12 +409,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;
@@ -420,9 +427,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,
@@ -434,8 +441,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;
@@ -448,7 +455,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;
@@ -461,7 +469,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;
@@ -473,19 +482,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;
@@ -516,7 +525,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));
 
@@ -530,13 +539,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);
     }
@@ -549,7 +558,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);
@@ -560,7 +569,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;
@@ -571,14 +580,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;
@@ -589,9 +598,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;
@@ -617,7 +626,7 @@ void acpi_build_tables(struct acpi_config *config)
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
 
-    if ( !new_vm_gid(config, acpi_info) )
+    if ( !new_vm_gid(ctxt, config, acpi_info) )
         goto oom;
 
     return;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index b411a6e..35b6f47 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -40,6 +40,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;
@@ -76,7 +84,7 @@ struct acpi_config {
     unsigned int rsdp;
 };
 
-void acpi_build_tables(struct acpi_config *config);
+void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
 
 #endif /* __LIBACPI_H__ */
 
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index b345576..3a423ab 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -866,10 +866,28 @@ 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)
+{
+    /* ACPI builder currently doesn't free memory so this is just a stub */
+}
+
 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 +952,11 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     config->rsdp = physical;
     config->infop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-    acpi_build_tables(config);
+    ctxt.mem_ops.alloc = acpi_mem_alloc;
+    ctxt.mem_ops.free = acpi_mem_free;
+    ctxt.mem_ops.v2p = acpi_v2p;
+
+    acpi_build_tables(&ctxt, config);
 
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->vm_gid_addr);
 }
-- 
1.8.3.1


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

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

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

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

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

diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index 1dd9987..b295ef0 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -145,7 +145,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));
@@ -162,7 +162,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;
 }
@@ -328,7 +329,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;
     }
@@ -355,7 +356,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. */
@@ -363,7 +364,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. */
@@ -372,7 +373,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 )
@@ -380,7 +381,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 )
@@ -388,7 +389,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");
     }
@@ -398,7 +399,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");
     }
@@ -412,12 +413,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);
@@ -445,11 +446,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");
     }
@@ -563,8 +564,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));
@@ -572,10 +573,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));
@@ -590,7 +591,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);
@@ -603,7 +604,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);
@@ -617,8 +618,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     rsdp = (struct acpi_20_rsdp *)config->rsdp;
 
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
-    rsdp->rsdt_address = (unsigned long)rsdt;
-    rsdp->xsdt_address = (unsigned long)xsdt;
+    rsdp->rsdt_address = ctxt->mem_ops.v2p(ctxt, rsdt);
+    rsdp->xsdt_address = ctxt->mem_ops.v2p(ctxt, xsdt);
     set_checksum(rsdp,
                  offsetof(struct acpi_10_rsdp, checksum),
                  sizeof(struct acpi_10_rsdp));
-- 
1.8.3.1


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

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

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

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* Added a suffix to iasl's -p option to work around a bug in older
  iasl versions where it drops everything after rightmost '.'.

 .gitignore                             |  8 +++---
 tools/firmware/hvmloader/Makefile      | 11 +++++++-
 tools/firmware/hvmloader/acpi/Makefile | 48 ++++++++++++++++------------------
 3 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/.gitignore b/.gitignore
index 6dee857..5720e0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt
 tools/firmware/etherboot/gpxe/*
 tools/firmware/extboot/extboot.img
 tools/firmware/extboot/signrom
-tools/firmware/hvmloader/acpi/mk_dsdt
-tools/firmware/hvmloader/acpi/dsdt*.c
-tools/firmware/hvmloader/acpi/dsdt_*cpu*.asl
-tools/firmware/hvmloader/acpi/ssdt_*.h
+tools/firmware/hvmloader/dsdt*.c
+tools/firmware/hvmloader/dsdt_*.asl
 tools/firmware/hvmloader/hvmloader
+tools/firmware/hvmloader/mk_dsdt
 tools/firmware/hvmloader/roms.h
 tools/firmware/hvmloader/roms.inc
+tools/firmware/hvmloader/ssdt_*.h
 tools/firmware/rombios/BIOS-bochs-[^/]*
 tools/firmware/rombios/_rombios[^/]*_.c
 tools/firmware/rombios/rombios[^/]*.s
diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 23b0a58..2565832 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -20,6 +20,7 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
+export ACPI_BUILD_DIR=$(CURDIR)
 SUBDIRS := acpi
 
 # The HVM loader is started in 32-bit mode at the address below:
@@ -76,7 +77,15 @@ all: subdirs-all
 rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
-hvmloader: $(OBJS) acpi/acpi.a
+ACPI_PATH = acpi
+ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
+$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
+vpath build.c $(ACPI_PATH)
+vpath static_tables.c $(ACPI_PATH)
+OBJS += $(ACPI_OBJS)
+
+hvmloader: $(OBJS)
 	$(LD) $(LDFLAGS_DIRECT) -N -Ttext $(LOADADDR) -o hvmloader.tmp $^
 	$(OBJCOPY) hvmloader.tmp hvmloader
 	rm -f hvmloader.tmp
diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/firmware/hvmloader/acpi/Makefile
index c6382bd..4045ea7 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/firmware/hvmloader/acpi/Makefile
@@ -15,41 +15,45 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-C_SRC-$(GPL) 	= build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
-C_SRC		= build.c static_tables.c $(C_SRC-y)
-OBJS  = $(patsubst %.c,%.o,$(C_SRC))
+# Used as a workaround for a bug in some older iasl versions where
+# the tool will ignore everything after last '.' in the path ('-p' argument)
+TMP_SUFFIX	= tmp__
 
-CFLAGS += $(CFLAGS_xeninclude)
+MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
+
+C_SRC-$(GPL) 	= dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+C_SRC		= $(addprefix $(ACPI_BUILD_DIR)/, $(C_SRC-y))
+H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
-all: acpi.a
+all: $(C_SRC) $(H_SRC)
 
-ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
-	iasl -vs -p $* -tc $<
-	sed -e 's/AmlCode/$*/g' $*.hex >$@
-	rm -f $*.hex $*.aml
+$(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $<
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
+	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
 
-mk_dsdt: mk_dsdt.c
+$(MK_DSDT): mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
 ifeq ($(GPL),y)
-dsdt_anycpu_qemu_xen.asl: gpl/dsdt.asl dsdt_acpi_info.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: gpl/dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
 	cat dsdt_acpi_info.asl >> $@
-	./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-dsdt_%cpu.asl: gpl/dsdt.asl dsdt_acpi_info.asl mk_dsdt
+$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: gpl/dsdt.asl $(MK_DSDT)
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
 	cat dsdt_acpi_info.asl >> $@
-	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
+	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
 endif
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
-	iasl -vs -p $* -tc $*.asl
-	sed -e 's/AmlCode/$*/g' $*.hex >$@
+$(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
+	iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
-	rm -f $*.aml $*.hex
+	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
 
 iasl:
 	@echo
@@ -59,14 +63,8 @@ iasl:
 	@echo 
 	@exit 1
 
-build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h
-
-acpi.a: $(OBJS)
-	$(AR) rc $@ $(OBJS)
-
 clean:
-	rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
-	rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*cpu*.asl
+	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC))
 
 distclean: clean
 
-- 
1.8.3.1


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

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

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

In prepearation to moving acpi sources into generally available
libacpi:

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* Include xen/memory.h in build.c
* lapic_id() returns uint8_t


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

diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 2565832..7b3641c 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -80,7 +80,8 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 ACPI_PATH = acpi
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
 ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
-$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I.
+$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"../util.h\"
+CFLAGS += -I$(ACPI_PATH)
 vpath build.c $(ACPI_PATH)
 vpath static_tables.c $(ACPI_PATH)
 OBJS += $(ACPI_OBJS)
diff --git a/tools/firmware/hvmloader/acpi/README b/tools/firmware/hvmloader/acpi/README
index 210d5ba..2b9d6e1 100644
--- a/tools/firmware/hvmloader/acpi/README
+++ b/tools/firmware/hvmloader/acpi/README
@@ -1,11 +1,19 @@
-ACPI Table for domain firmware
+ACPI builder for domain firmware
 
 
-INSTALL
+BUILDING ACPI
 -----------------
-Simply make is OK.
-# make 
+Users of ACPI builder are expected to provide an include file that makes available
+the following:
+* strncpy
+* printf
+* NULL
+* test_bit
+* offsetof
 
+When compiling build.c, the name of this include file should be given to
+compiler as -DLIBACPI_STDUTILS=\"<filename>\". See tools/firmware/hvmloader/Makefile
+for an example.
 
 Note on DSDT Table
 ------------------
diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c
index b295ef0..00fb67e 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -13,15 +13,13 @@
  * GNU Lesser General Public License for more details.
  */
 
+#include LIBACPI_STDUTILS
 #include "acpi2_0.h"
 #include "libacpi.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
-#include "../config.h"
-#include "../util.h"
-#include "../vnuma.h"
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 #include <xen/memory.h>
@@ -82,6 +80,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
     const 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);
@@ -98,7 +99,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 )
@@ -117,7 +118,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;
@@ -136,8 +137,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);
     }
@@ -153,7 +154,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++;
@@ -241,7 +242,7 @@ static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt,
         processor->type     = ACPI_PROCESSOR_AFFINITY;
         processor->length   = sizeof(*processor);
         processor->domain   = config->numa.vcpu_to_vnode[i];
-        processor->apic_id  = LAPIC_ID(i);
+        processor->apic_id  = config->lapic_id(i);
         processor->flags    = ACPI_LOCAL_APIC_AFFIN_ENABLED;
         processor++;
     }
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h
index 35b6f47..e386362 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -82,6 +82,13 @@ struct acpi_config {
 
     /* RSDP address */
     unsigned int rsdp;
+
+    /* x86-specific parameters */
+    uint8_t (*lapic_id)(unsigned cpu);
+    uint32_t lapic_base_address;
+    uint32_t ioapic_base_address;
+    uint16_t pci_isa_irq_mask;
+    uint8_t ioapic_id;
 };
 
 void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
index bbd4e34..77b9536 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -24,8 +24,8 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
-#include "acpi/acpi2_0.h"
 #include "vnuma.h"
+#include <acpi2_0.h>
 #include <xen/version.h>
 #include <xen/hvm/params.h>
 #include <xen/arch-x86/hvm/start_info.h>
diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c
index 1e853ec..0df59f3 100644
--- a/tools/firmware/hvmloader/rombios.c
+++ b/tools/firmware/hvmloader/rombios.c
@@ -24,12 +24,12 @@
 #include "../rombios/config.h"
 
 #include "smbios_types.h"
-#include "acpi/libacpi.h"
 #include "pci_regs.h"
 #include "util.h"
 #include "hypercall.h"
 #include "option_rom.h"
 
+#include <libacpi.h>
 #include <xen/hvm/params.h>
 #include <xen-tools/libs.h>
 
diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
index 44ff0d7..870576a 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/tools/firmware/hvmloader/seabios.c
@@ -25,8 +25,9 @@
 #include "util.h"
 
 #include "smbios_types.h"
-#include "acpi/acpi2_0.h"
-#include "acpi/libacpi.h"
+
+#include <acpi2_0.h>
+#include <libacpi.h>
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index 3a423ab..6e0cfe7 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -22,8 +22,8 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "vnuma.h"
-#include "acpi/acpi2_0.h"
-#include "acpi/libacpi.h"
+#include <acpi2_0.h>
+#include <libacpi.h>
 #include <stdint.h>
 #include <xen/xen.h>
 #include <xen/memory.h>
@@ -883,6 +883,11 @@ static void acpi_mem_free(struct acpi_ctxt *ctxt,
     /* ACPI builder currently doesn't free memory so this is just a stub */
 }
 
+static uint8_t acpi_lapic_id(unsigned cpu)
+{
+    return LAPIC_ID(cpu);
+}
+
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical)
 {
@@ -892,6 +897,12 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     /* Allocate and initialise the acpi info area. */
     mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1);
 
+    config->lapic_base_address = LAPIC_BASE_ADDRESS;
+    config->lapic_id = acpi_lapic_id;
+    config->ioapic_base_address = ioapic_base_address;
+    config->ioapic_id = IOAPIC_ID;
+    config->pci_isa_irq_mask = PCI_ISA_IRQ_MASK; 
+
     if ( uart_exists(0x3f8)  )
         config->table_flags |= ACPI_HAS_COM1;
     if (  uart_exists(0x2f8) )
diff --git a/tools/firmware/rombios/32bit/Makefile b/tools/firmware/rombios/32bit/Makefile
index 396906c..71399d2 100644
--- a/tools/firmware/rombios/32bit/Makefile
+++ b/tools/firmware/rombios/32bit/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi
 
 SUBDIRS = tcgbios
 
diff --git a/tools/firmware/rombios/32bit/tcgbios/Makefile b/tools/firmware/rombios/32bit/tcgbios/Makefile
index f6f2649..6822027 100644
--- a/tools/firmware/rombios/32bit/tcgbios/Makefile
+++ b/tools/firmware/rombios/32bit/tcgbios/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../..
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi
 
 .PHONY: all
 all: $(TARGET)
diff --git a/tools/firmware/rombios/32bit/util.h b/tools/firmware/rombios/32bit/util.h
index e245be6..6b90c43 100644
--- a/tools/firmware/rombios/32bit/util.h
+++ b/tools/firmware/rombios/32bit/util.h
@@ -1,7 +1,7 @@
 #ifndef UTIL_H
 #define UTIL_H
 
-#include "../hvmloader/acpi/acpi2_0.h"
+#include <acpi2_0.h>
 
 void outb(uint16_t addr, uint8_t val);
 void outw(uint16_t addr, uint16_t val);
-- 
1.8.3.1


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

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

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 MAINTAINERS                                                |  1 +
 tools/firmware/hvmloader/Makefile                          | 14 ++++++++------
 tools/firmware/hvmloader/ovmf.c                            |  2 +-
 tools/firmware/rombios/32bit/Makefile                      |  2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile              |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/Makefile        |  2 +-
 tools/{firmware/hvmloader/acpi => libacpi}/README          |  0
 tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h       |  0
 tools/{firmware/hvmloader/acpi => libacpi}/build.c         |  0
 .../hvmloader/acpi => libacpi}/dsdt_acpi_info.asl          |  0
 tools/{firmware/hvmloader/acpi => libacpi}/gpl/COPYING     |  0
 tools/{firmware/hvmloader/acpi => libacpi}/gpl/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
 19 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_acpi_info.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/gpl/COPYING (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/gpl/dsdt.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl (100%)
 rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 97720a8..07545f3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -138,6 +138,7 @@ S:	Supported
 F:	xen/arch/x86/acpi/
 F:	xen/drivers/acpi/
 F:	xen/include/acpi/
+F:	tools/libacpi/
 
 AMD IOMMU
 M:	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 7b3641c..c19986a 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -20,10 +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:
 LOADADDR = 0x100000
 
 # SMBIOS spec requires format mm/dd/yyyy
@@ -71,16 +68,20 @@ GPL = y
 export GPL
 
 .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)
@@ -122,6 +123,7 @@ endif
 clean: subdirs-clean
 	rm -f roms.inc roms.inc.new acpi.h
 	rm -f hvmloader hvmloader.tmp *.o $(DEPS)
+	$(MAKE) -C $(ACPI_PATH)  ACPI_BUILD_DIR=$(CURDIR) clean
 
 .PHONY: distclean
 distclean: clean
diff --git a/tools/firmware/hvmloader/ovmf.c b/tools/firmware/hvmloader/ovmf.c
index 0ac3416..4ff7f1d 100644
--- a/tools/firmware/hvmloader/ovmf.c
+++ b/tools/firmware/hvmloader/ovmf.c
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "smbios_types.h"
-#include "acpi/libacpi.h"
+#include "libacpi.h"
 #include "apic_regs.h"
 #include "../rombios/config.h"
 #include "util.h"
diff --git a/tools/firmware/rombios/32bit/Makefile b/tools/firmware/rombios/32bit/Makefile
index 71399d2..b0583c9 100644
--- a/tools/firmware/rombios/32bit/Makefile
+++ b/tools/firmware/rombios/32bit/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi
 
 SUBDIRS = tcgbios
 
diff --git a/tools/firmware/rombios/32bit/tcgbios/Makefile b/tools/firmware/rombios/32bit/tcgbios/Makefile
index 6822027..f87d130 100644
--- a/tools/firmware/rombios/32bit/tcgbios/Makefile
+++ b/tools/firmware/rombios/32bit/tcgbios/Makefile
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../../libacpi
 
 .PHONY: all
 all: $(TARGET)
diff --git a/tools/firmware/hvmloader/acpi/Makefile b/tools/libacpi/Makefile
similarity index 98%
rename from tools/firmware/hvmloader/acpi/Makefile
rename to tools/libacpi/Makefile
index 4045ea7..fdb08e6 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -12,7 +12,7 @@
 # NU Lesser General Public License for more details.
 #
 
-XEN_ROOT = $(CURDIR)/../../../..
+XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 # Used as a workaround for a bug in some older iasl versions where
diff --git a/tools/firmware/hvmloader/acpi/README b/tools/libacpi/README
similarity index 100%
rename from tools/firmware/hvmloader/acpi/README
rename to tools/libacpi/README
diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
similarity index 100%
rename from tools/firmware/hvmloader/acpi/acpi2_0.h
rename to tools/libacpi/acpi2_0.h
diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/libacpi/build.c
similarity index 100%
rename from tools/firmware/hvmloader/acpi/build.c
rename to tools/libacpi/build.c
diff --git a/tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl b/tools/libacpi/dsdt_acpi_info.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl
rename to tools/libacpi/dsdt_acpi_info.asl
diff --git a/tools/firmware/hvmloader/acpi/gpl/COPYING b/tools/libacpi/gpl/COPYING
similarity index 100%
rename from tools/firmware/hvmloader/acpi/gpl/COPYING
rename to tools/libacpi/gpl/COPYING
diff --git a/tools/firmware/hvmloader/acpi/gpl/dsdt.asl b/tools/libacpi/gpl/dsdt.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/gpl/dsdt.asl
rename to tools/libacpi/gpl/dsdt.asl
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/libacpi/libacpi.h
similarity index 100%
rename from tools/firmware/hvmloader/acpi/libacpi.h
rename to tools/libacpi/libacpi.h
diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
similarity index 100%
rename from tools/firmware/hvmloader/acpi/mk_dsdt.c
rename to tools/libacpi/mk_dsdt.c
diff --git a/tools/firmware/hvmloader/acpi/ssdt_pm.asl b/tools/libacpi/ssdt_pm.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_pm.asl
rename to tools/libacpi/ssdt_pm.asl
diff --git a/tools/firmware/hvmloader/acpi/ssdt_s3.asl b/tools/libacpi/ssdt_s3.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s3.asl
rename to tools/libacpi/ssdt_s3.asl
diff --git a/tools/firmware/hvmloader/acpi/ssdt_s4.asl b/tools/libacpi/ssdt_s4.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_s4.asl
rename to tools/libacpi/ssdt_s4.asl
diff --git a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl b/tools/libacpi/ssdt_tpm.asl
similarity index 100%
rename from tools/firmware/hvmloader/acpi/ssdt_tpm.asl
rename to tools/libacpi/ssdt_tpm.asl
diff --git a/tools/firmware/hvmloader/acpi/static_tables.c b/tools/libacpi/static_tables.c
similarity index 100%
rename from tools/firmware/hvmloader/acpi/static_tables.c
rename to tools/libacpi/static_tables.c
-- 
1.8.3.1


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

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

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

PVHv2 guests may request LAPIC emulation (and nothing else)

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

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


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

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

* [PATCH v4 14/21] libacpi: Build DSDT for PVH guests
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (12 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 13/21] x86: Allow LAPIC-only emulation_flags for HVM guests Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-21 11:27   ` Jan Beulich
  2016-09-20  0:19 ` [PATCH v4 15/21] acpi: Makefile should better tolerate interrupts Boris Ostrovsky
                   ` (6 subsequent siblings)
  20 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 tools/libacpi/Makefile  | 7 ++++++-
 tools/libacpi/mk_dsdt.c | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index fdb08e6..83d6a8f 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -22,7 +22,7 @@ TMP_SUFFIX	= tmp__
 MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
 
 C_SRC-$(GPL) 	= dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
-C_SRC		= $(addprefix $(ACPI_BUILD_DIR)/, $(C_SRC-y))
+C_SRC		= $(addprefix $(ACPI_BUILD_DIR)/, dsdt_pvh.c $(C_SRC-y))
 H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h)
 
 vpath iasl $(PATH)
@@ -49,6 +49,11 @@ $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: gpl/dsdt.asl $(MK_DSDT)
 	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@
 endif
 
+$(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)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl
 	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index e750820..8130cbd 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -23,6 +23,7 @@ static unsigned int indent_level;
 static bool debug = false;
 
 typedef enum dm_version {
+    QEMU_NONE,
     QEMU_XEN_TRADITIONAL,
     QEMU_XEN,
 } dm_version;
@@ -135,6 +136,8 @@ int main(int argc, char **argv)
                 dm_version = QEMU_XEN;
             } else if (strcmp(optarg, "qemu-xen-traditional") == 0) {
                 dm_version = QEMU_XEN_TRADITIONAL;
+            } else if (strcmp(optarg, "none") == 0) {
+                dm_version = QEMU_NONE;
             } else {
                 fprintf(stderr, "Unknown device model version `%s'.\n", optarg);
                 return -1;
@@ -252,6 +255,11 @@ int main(int argc, char **argv)
 
     pop_block();
 
+    if (dm_version == QEMU_NONE) {
+        pop_block();
+        return 0;
+    }
+
     /* Define GPE control method. */
     push_block("Scope", "\\_GPE");
     push_block("Method",
-- 
1.8.3.1


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

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

* [PATCH v4 15/21] acpi: Makefile should better tolerate interrupts
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (13 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 14/21] libacpi: Build DSDT for PVH guests Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 16/21] libxc/libxl: Allow multiple ACPI modules Boris Ostrovsky
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* Instead of storing those intermediate files in /tmp keep then locally
  by adding TMP_SUFFIX to target.

 tools/libacpi/Makefile | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile
index 83d6a8f..68351c7 100644
--- a/tools/libacpi/Makefile
+++ b/tools/libacpi/Makefile
@@ -15,7 +15,8 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-# Used as a workaround for a bug in some older iasl versions where
+# Suffix for temporary files.
+# Also used as a workaround for a bug in some older iasl versions where
 # the tool will ignore everything after last '.' in the path ('-p' argument)
 TMP_SUFFIX	= tmp__
 
@@ -38,26 +39,30 @@ $(MK_DSDT): mk_dsdt.c
 
 ifeq ($(GPL),y)
 $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: gpl/dsdt.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}' $< > $@.$(TMP_SUFFIX)
+	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
+	$(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)
+	mv -f $@.$(TMP_SUFFIX) $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
 $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: gpl/dsdt.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}' $< > $@.$(TMP_SUFFIX)
+	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
+	$(MK_DSDT) --debug=$(debug) --maxcpu $*  >> $@.$(TMP_SUFFIX)
+	mv -f $@.$(TMP_SUFFIX) $@
 endif
 
 $(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{" > $@.$(TMP_SUFFIX)
+	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
+	$(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@.$(TMP_SUFFIX)
+	mv -f $@.$(TMP_SUFFIX) $@
 
 $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl
 	iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl
-	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
-	echo "int $*_len=sizeof($*);" >>$@
+	sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@.$(TMP_SUFFIX)
+	echo "int $*_len=sizeof($*);" >>$@.$(TMP_SUFFIX)
+	mv -f $@.$(TMP_SUFFIX) $@
 	rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex)
 
 iasl:
@@ -70,6 +75,7 @@ iasl:
 
 clean:
 	rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC))
+	rm -f $(C_SRC:=.$(TMP_SUFFIX)) $(patsubst %.c,%.hex,$(C_SRC)) $(patsubst %.c,%.aml,$(C_SRC))
 
 distclean: clean
 
-- 
1.8.3.1


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

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

* [PATCH v4 16/21] libxc/libxl: Allow multiple ACPI modules
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (14 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 15/21] acpi: Makefile should better tolerate interrupts Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 17/21] libxl/acpi: Add ACPI e820 entry Boris Ostrovsky
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

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

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxc/include/xc_dom.h   |  5 +++--
 tools/libxc/xc_dom_hvmloader.c |  3 ++-
 tools/libxl/libxl_dom.c        | 26 ++++++++++++++++++--------
 3 files changed, 23 insertions(+), 11 deletions(-)

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


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

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

* [PATCH v4 17/21] libxl/acpi: Add ACPI e820 entry
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (15 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 16/21] libxc/libxl: Allow multiple ACPI modules Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-20  0:19 ` [PATCH v4 18/21] libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests Boris Ostrovsky
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_dom.c |  8 ++++----
 tools/libxl/libxl_x86.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

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


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

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

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

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/Makefile     |  2 ++
 tools/libxl/libxl_arch.h |  6 ++++++
 tools/libxl/libxl_dom.c  | 19 +++++++++++++++----
 3 files changed, 23 insertions(+), 4 deletions(-)

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


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

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

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

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

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

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


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

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

* [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-20  0:19 [PATCH v4 00/21] Make ACPI builder available to components other than hvmloader Boris Ostrovsky
                   ` (18 preceding siblings ...)
  2016-09-20  0:19 ` [PATCH v4 19/21] ilibxl: Initialize domain build info before calling libxl__domain_make Boris Ostrovsky
@ 2016-09-20  0:19 ` Boris Ostrovsky
  2016-09-21 11:33   ` Jan Beulich
  2016-09-22 10:53   ` Wei Liu
  2016-09-20  0:19 ` [PATCH v4 21/21] libxc/xc_dom_core: Copy ACPI tables to guest space Boris Ostrovsky
  20 siblings, 2 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20  0:19 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, andrew.cooper3, ian.jackson, julien.grall, jbeulich,
	zhaoshenglong, Boris Ostrovsky, roger.pau

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* Remove allocation-specific fields from struct acpi_ctxt and use
  an enclosing struct libxl_acpi_ctxt.
* Use private struct hvminfo (to deal with constified struct
  acpi_config->hvminfo)

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

diff --git a/.gitignore b/.gitignore
index 5720e0f..9b6f58e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -173,15 +173,19 @@ tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libxl/libxlu_cfg_y.output
+tools/libxl/_libxl.api-for-check
+tools/libxl/*.api-ok
 tools/libxl/*.pc
 tools/libxl/*.pc.in
-tools/libxl/xl
+tools/libxl/dsdt*.c
+tools/libxl/dsdt_*.asl
+tools/libxl/libxlu_cfg_y.output
+tools/libxl/mk_dsdt
+tools/libxl/ssdt_*.h
 tools/libxl/testenum
 tools/libxl/testenum.c
 tools/libxl/tmp.*
-tools/libxl/_libxl.api-for-check
-tools/libxl/*.api-ok
+tools/libxl/xl
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
index 00fb67e..47dae01 100644
--- a/tools/libacpi/build.c
+++ b/tools/libacpi/build.c
@@ -20,6 +20,7 @@
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
+#include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 #include <xen/memory.h>
@@ -496,7 +497,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;
@@ -631,11 +632,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
     if ( !new_vm_gid(ctxt, config, acpi_info) )
         goto oom;
 
-    return;
+    return 0;
 
 oom:
     printf("unable to build ACPI tables: out of memory\n");
-
+    return -1;
 }
 
 /*
diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h
index e386362..1d388f9 100644
--- a/tools/libacpi/libacpi.h
+++ b/tools/libacpi/libacpi.h
@@ -78,10 +78,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 */
     uint8_t (*lapic_id)(unsigned cpu);
@@ -91,7 +91,7 @@ struct acpi_config {
     uint8_t ioapic_id;
 };
 
-void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
+int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
 
 #endif /* __LIBACPI_H__ */
 
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 90427ff..336358c 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -75,7 +75,21 @@ else
 LIBXL_OBJS-y += libxl_no_colo.o
 endif
 
-LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
+ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
+ACPI_FILES = dsdt_pvh.c
+ACPI_OBJS  = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
+$(ACPI_FILES): acpi
+$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
+vpath build.c $(ACPI_PATH)/
+vpath static_tables.c $(ACPI_PATH)/
+LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
+
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
+-include acpi
+
+LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
 
 ifeq ($(CONFIG_NetBSD),y)
@@ -167,6 +181,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
 $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
 
 libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
+libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
 
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
@@ -309,6 +324,7 @@ clean:
 	$(RM) -f testidl.c.new testidl.c *.api-ok
 	$(RM) -f xenlight.pc
 	$(RM) -f xlutil.pc
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
 
 distclean: clean
 	$(RM) -f xenlight.pc.in xlutil.pc.in
diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index 253a037..7a70b01 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -66,6 +66,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
 
+int libxl__dom_load_acpi(libxl__gc *gc,
+			 const libxl_domain_build_info *b_info,
+			 struct xc_dom_image *dom);
 #endif
 
 #endif
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 2b221aa..d10b04b 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -8,15 +8,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
                                       xc_domain_configuration_t *xc_config)
 {
 
-    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
-        d_config->b_info.device_model_version !=
-        LIBXL_DEVICE_MODEL_VERSION_NONE) {
-        /* HVM domains with a device model. */
-        xc_config->emulation_flags = XEN_X86_EMU_ALL;
-    } else {
-        /* PV or HVM domains without a device model. */
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
+        if (d_config->b_info.device_model_version !=
+            LIBXL_DEVICE_MODEL_VERSION_NONE) {
+            xc_config->emulation_flags = XEN_X86_EMU_ALL;
+        } else if (libxl_defbool_val(d_config->b_info.u.hvm.apic)) {
+            /*
+             * HVM guests without device model may want
+             * to have LAPIC emulation.
+             */
+            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
+        }
+    } else 
         xc_config->emulation_flags = 0;
-    }
 
     return 0;
 }
@@ -366,7 +370,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
                                                libxl_domain_build_info *info,
                                                struct xc_dom_image *dom)
 {
-    return 0;
+    int ret = 0;
+
+    if ((info->type == LIBXL_DOMAIN_TYPE_HVM) &&
+        (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE)) {
+        if ( (ret = libxl__dom_load_acpi(gc, info, dom)) != 0 )
+            LOGE(ERROR, "libxl_dom_load_acpi failed");
+    }
+
+    return ret;
 }
 
 /* Return 0 on success, ERROR_* on failure. */
diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libxl/libxl_x86_acpi.c
new file mode 100644
index 0000000..1b38116
--- /dev/null
+++ b/tools/libxl/libxl_x86_acpi.c
@@ -0,0 +1,243 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "libxl_internal.h"
+#include "libxl_arch.h"
+#include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/e820.h>
+#include "libacpi/libacpi.h"
+
+#include <xc_dom.h>
+
+ /* Number of pages holding ACPI tables */
+#define NUM_ACPI_PAGES 16
+/* Store RSDP in the last 64 bytes of BIOS RO memory */
+#define RSDP_ADDRESS (0x100000 - 64)
+#define ACPI_INFO_PHYSICAL_ADDRESS 0xfc000000
+
+struct libxl_acpi_ctxt {
+    struct acpi_ctxt c;
+
+    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;
+};
+
+extern const unsigned char dsdt_pvh[];
+extern const unsigned int dsdt_pvh_len;
+
+/* Assumes contiguous physical space */
+static unsigned long virt_to_phys(struct acpi_ctxt *ctxt, void *v)
+{
+    struct libxl_acpi_ctxt *libxl_ctxt =
+        CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c);
+
+    return (((unsigned long)v - libxl_ctxt->alloc_base_vaddr) +
+            libxl_ctxt->alloc_base_paddr);
+}
+
+static void *mem_alloc(struct acpi_ctxt *ctxt,
+                       uint32_t size, uint32_t align)
+{
+    struct libxl_acpi_ctxt *libxl_ctxt =
+        CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c);
+    unsigned long s, e;
+
+    /* Align to at least 16 bytes. */
+    if (align < 16)
+        align = 16;
+
+    s = (libxl_ctxt->alloc_currp + align) & ~((unsigned long)align - 1);
+    e = s + size - 1;
+
+    /* TODO: Reallocate memory */
+    if ((e < s) || (e >= libxl_ctxt->alloc_end))
+        return NULL;
+
+    while (libxl_ctxt->alloc_currp >> libxl_ctxt->page_shift != 
+           e >> libxl_ctxt->page_shift)
+        libxl_ctxt->alloc_currp += libxl_ctxt->page_size;
+
+    libxl_ctxt->alloc_currp = e;
+
+    return (void *)s;
+}
+
+static void acpi_mem_free(struct acpi_ctxt *ctxt,
+                          void *v, uint32_t size)
+{
+}
+
+static uint8_t acpi_lapic_id(unsigned cpu)
+{
+    return cpu * 2;
+}
+
+static int init_acpi_config(libxl__gc *gc, 
+                            struct xc_dom_image *dom,
+                            const libxl_domain_build_info *b_info,
+                            struct acpi_config *config)
+{
+    xc_interface *xch = dom->xch;
+    uint32_t domid = dom->guest_domid;
+    xc_dominfo_t info;
+    struct hvm_info_table *hvminfo;
+    int i, rc;
+
+    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_pvh;
+    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_pvh_len;
+
+    rc = xc_domain_getinfo(xch, domid, 1, &info);
+    if (rc < 0) {
+        LOG(ERROR, "%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    hvminfo = libxl__zalloc(gc, sizeof(*hvminfo));
+
+    hvminfo->apic_mode = libxl_defbool_val(b_info->u.hvm.apic);
+
+    if (dom->nr_vnodes) {
+        unsigned int *vcpu_to_vnode, *vdistance;
+        struct xen_vmemrange *vmemrange;
+        struct acpi_numa *numa = &config->numa;
+
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges,
+                                &hvminfo->nr_vcpus, NULL, NULL, NULL);
+        if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+
+        vmemrange = libxl__zalloc(gc, dom->nr_vmemranges * sizeof(*vmemrange));
+        vdistance = libxl__zalloc(gc, dom->nr_vnodes * sizeof(*vdistance));
+        vcpu_to_vnode = libxl__zalloc(gc, hvminfo->nr_vcpus *
+                                      sizeof(*vcpu_to_vnode));
+        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
+                                &numa->nr_vmemranges, &hvminfo->nr_vcpus,
+                                vmemrange, vdistance, vcpu_to_vnode);
+	if (rc) {
+            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
+                __FUNCTION__, rc);
+            return rc;
+        }
+        numa->vmemrange = vmemrange;
+        numa->vdistance = vdistance;
+        numa->vcpu_to_vnode = vcpu_to_vnode;
+    }
+    else
+        hvminfo->nr_vcpus = info.max_vcpu_id + 1;
+
+    for (i = 0; i < hvminfo->nr_vcpus; i++)
+        hvminfo->vcpu_online[i / 8] |= 1 << (i & 7);
+
+    config->hvminfo = hvminfo;
+
+    config->lapic_base_address = LAPIC_BASE_ADDRESS;
+    config->lapic_id = acpi_lapic_id;
+
+    return 0;
+}
+
+int libxl__dom_load_acpi(libxl__gc *gc,
+                         const libxl_domain_build_info *b_info,
+                         struct xc_dom_image *dom)
+{
+    struct acpi_config config = {0};
+    struct libxl_acpi_ctxt libxl_ctxt;
+    int rc, acpi_pages_num;
+    void *acpi_pages;
+    unsigned long page_mask;
+
+    if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) ||
+        (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE))
+        return 0;
+
+    libxl_ctxt.page_size = XC_DOM_PAGE_SIZE(dom);
+    libxl_ctxt.page_shift =  XC_DOM_PAGE_SHIFT(dom);
+    page_mask = (1UL << libxl_ctxt.page_shift) - 1;
+
+    libxl_ctxt.c.mem_ops.alloc = mem_alloc;
+    libxl_ctxt.c.mem_ops.v2p = virt_to_phys;
+    libxl_ctxt.c.mem_ops.free = acpi_mem_free;
+
+    rc = init_acpi_config(gc, dom, b_info, &config);
+    if (rc) {
+        LOG(ERROR, "%s: init_acpi_config failed (rc=%d)", __FUNCTION__, rc);
+        return rc;
+    }
+
+    config.rsdp = (unsigned long)libxl__malloc(gc, libxl_ctxt.page_size);
+    config.infop = (unsigned long)libxl__malloc(gc, libxl_ctxt.page_size);
+    /* Pages to hold ACPI tables */
+    acpi_pages =  libxl__malloc(gc, (NUM_ACPI_PAGES + 1) *
+                                libxl_ctxt.page_size);
+
+    /*
+     * Set up allocator memory.
+     * Start next to acpi_info page to avoid fracturing e820.
+     */
+    libxl_ctxt.alloc_base_paddr = ACPI_INFO_PHYSICAL_ADDRESS +
+        libxl_ctxt.page_size;
+    libxl_ctxt.alloc_base_vaddr = libxl_ctxt.alloc_currp =
+        (unsigned long)acpi_pages;
+    libxl_ctxt.alloc_end = (unsigned long)acpi_pages +
+        (NUM_ACPI_PAGES * libxl_ctxt.page_size);
+
+    /* Build the tables. */
+    rc = acpi_build_tables(&libxl_ctxt.c, &config);
+    if (rc) {
+        LOG(ERROR, "%s: acpi_build_tables failed with %d",
+            __FUNCTION__, rc);
+        goto out;
+    }
+
+    /* Calculate how many pages are needed for the tables. */
+    acpi_pages_num =
+        ((libxl_ctxt.alloc_currp - (unsigned long)acpi_pages)
+         >> libxl_ctxt.page_shift) +
+        ((libxl_ctxt.alloc_currp & page_mask) ? 1 : 0);
+
+    dom->acpi_modules[0].data = (void *)config.rsdp;
+    dom->acpi_modules[0].length = 64;
+    dom->acpi_modules[0].guest_addr_out = RSDP_ADDRESS;
+
+    dom->acpi_modules[1].data = (void *)config.infop;
+    dom->acpi_modules[1].length = 4096;
+    dom->acpi_modules[1].guest_addr_out = ACPI_INFO_PHYSICAL_ADDRESS;
+
+    dom->acpi_modules[2].data = acpi_pages;
+    dom->acpi_modules[2].length = acpi_pages_num  << libxl_ctxt.page_shift;
+    dom->acpi_modules[2].guest_addr_out = ACPI_INFO_PHYSICAL_ADDRESS +
+        libxl_ctxt.page_size;
+
+out:
+
+    return rc;
+
+}
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/libxl/libxl_x86_acpi.h b/tools/libxl/libxl_x86_acpi.h
new file mode 100644
index 0000000..3622dd0
--- /dev/null
+++ b/tools/libxl/libxl_x86_acpi.h
@@ -0,0 +1,35 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef LIBXL_X86_ACPI_H
+#define LIBXL_X86_ACPI_H
+
+#include "libxl_internal.h"
+
+#define ASSERT(x) assert(x)
+
+static inline int test_bit(unsigned int b, const void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}
+
+#endif /* LIBXL_X_86_ACPI_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.8.3.1


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

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

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

Load ACPI modules into guest space

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v4:
* Style updates

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

diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index ebada89..be3ccd7 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -1040,6 +1040,97 @@ 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 +1188,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
     }
 
+    /* load ACPI tables */
+    if ( xc_dom_load_acpi(dom) != 0 )
+        goto err;
+
     /* allocate other pages */
     if ( !dom->arch_hooks->p2m_base_supported ||
          dom->parms.p2m_base >= dom->parms.virt_base ||
-- 
1.8.3.1


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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20  0:19 ` [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries Boris Ostrovsky
@ 2016-09-20 10:14   ` Ian Jackson
  2016-09-20 10:41     ` Lars Kurth
  2016-09-20 14:07     ` Boris Ostrovsky
  2016-09-20 10:32   ` Lars Kurth
  2016-09-21 10:39   ` Jan Beulich
  2 siblings, 2 replies; 59+ messages in thread
From: Ian Jackson @ 2016-09-20 10:14 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

Boris Ostrovsky writes ("[PATCH v4 02/21] acpi: 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 under
> GPLv2. We want to prevent this code from showing up in non-GPL
> binaries which might become possible after we make ACPI builder code
> available to users other than hvmloader.
> 
> There are two pieces that we need to be careful about:
> (1) A small piece of code in dsdt.asl that implements _PIC method
> (2) A fragment of ASL generator in mk_dsdt.c that describes PCI
>     interrupt routing.
> 
> The cleanest way to deal with this seems to be taking generatedi ASL
> chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.

This approach leaves us with the whole of dsdt.asl declared to be
GPLv2.  If you are trying to relicence it as LGPLv2.1 this is not a
good idea.

Using this approach, if at some later point we get the missing ack
from Lenovo, we would have to redo the licence review for the whole of
dsdt.asl.  We would also have to ask Oracle's permission to relicense
bits of the build system etc. !

At the very least we should operate separate inbound/outbound
licensing for this one file.

But as I wrote on IRC, I think it would also be best to split out
_just the troublesome portions_ into their own files, and include them
at build time.  That way we have file-by-file source licensing.

Ian.

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

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

* Re: [PATCH v4 03/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
  2016-09-20  0:19 ` [PATCH v4 03/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 Boris Ostrovsky
@ 2016-09-20 10:17   ` Lars Kurth
  0 siblings, 0 replies; 59+ messages in thread
From: Lars Kurth @ 2016-09-20 10:17 UTC (permalink / raw)
  To: Boris Ostrovsky, xen-devel, Ian Jackson
  Cc: Kevin Tian, Wei Liu, Kouya Shimura, Andrew Cooper, julien.grall,
	Simon Horman, keke, jbeulich, zhaoshenglong, Stefan Berger,
	Keir (Xen.org),
	Daniel Kiper, Roger Pau Monne



On 20/09/2016 01:19, "Boris Ostrovsky" <boris.ostrovsky@oracle.com> wrote:

>ACPI builder is currently distributed under GPLv2 license.
>
>We plan to make the builder available to components other
>than the hvmloader (which is also GPLv2). Some of these
>components (such as libxl) may be distributed under LGPL-2.1
>so that they can be used by non-GPLv2 callers.  But this
>will not be possible if we incorporate the ACPI builder in
>those other components.
>
>To avoid this problem we are relicensing sources in ACPI
>bulder directory to the Lesser GNU Public License (LGPL)
>version 2.1
>
>(dsdt.asl remains GPLv2 as we might need permission from Lenovo
>due to commit 801d469ad ("[HVM] ACPI support patch 3 of 4: ACPI
>_PRT table."))
>
>Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>Acked-by: Daniel Kiper <dkiper@net-space.pl>
>Acked-by: Stefan Berger <stefanb@us.ibm.com>
>Acked-by: Kouya Shimura <kouya@jp.fujitsu.com>
>Acked-by: Jan Beulich <jbeulich@suse.com>
>Acked-by: Kevin Tian <kevin.tian@intel.com>
>Acked-by: Keir Fraser <keir@xen.org>
>Acked-by: Simon Horman <horms@verge.net.au>
>Acked-by: Lars Kurth <lars.kurth@citrix.com>
>Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [for Oracle,
>VirtualIron and Sun contributions]
>---
>CC: Daniel Kiper <dkiper@net-space.pl>
>CC: Stefan Berger <stefanb@us.ibm.com>
>CC: Kouya Shimura <kouya@jp.fujitsu.com>
>CC: Jan Beulich <jbeulich@suse.com>
>CC: Kevin Tian <kevin.tian@intel.com>
>CC: Keir Fraser <keir@xen.org>
>CC: Simon Horman <horms@verge.net.au>
>CC: Lars Kurth <lars.kurth@citrix.com>
>CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>CC: keke@lenovo.com
>---
>
>Changes in v4:
>* Dropped dsdt.asl until Lenovo ACK is received (note that mk_dsdt.c *is*
>made LGPL)
>
> tools/firmware/hvmloader/acpi/Makefile        | 18 ++++++++----------

The directory tools/firmware/hvmloader/acpi/ should contain a COPYING file
containing the text following text

[1] http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/COPYING


I would replace the following block in [1] with a more verbose
description, 
which provides additional context and states our intention.

1 Note that the only valid version of the LGPL as far as the files in
   2 this directory (and its subdirectories) are concerned is _this_
   3 particular version of the license (i.e., *only* v2.1, not v2.2 or v3.x
   4 or whatever), unless explicitly otherwise stated.

This library is licensed under LGPL v2.1 to allow its usage in LGPL-2.1
libraries such as libxl. Note that the only valid version of the LGPL as
far as the files in this directory (and its subdirectories) are concerned
is _this_ particular version of the license (i.e., *only* v2.1, not v2.2
or v3.x, unless explicitly otherwise stated.

After this block


6 Where clause 3 is invoked in order to relicense under the GPL then
   7 this shall be considered to be GPL v2 only for files which have
   8 specified LGPL v2.1 only.

add



gpl sub-directory
=================
This directory contains a gpl sub-directory which contains code licensed
under the GPL v2, because we have not yet been able to get the permission
to relicense the relevant code to LGPL v2.1. See gpl/COPYING for more
information.

The makefile in this component allows to build a GPL and LGPL only
variant of this library, the latter omits all GPL source code.

Regards
Lars

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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20  0:19 ` [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries Boris Ostrovsky
  2016-09-20 10:14   ` Ian Jackson
@ 2016-09-20 10:32   ` Lars Kurth
  2016-09-21 10:39   ` Jan Beulich
  2 siblings, 0 replies; 59+ messages in thread
From: Lars Kurth @ 2016-09-20 10:32 UTC (permalink / raw)
  To: Boris Ostrovsky, xen-devel, Ian Jackson
  Cc: Wei Liu, Andrew Cooper, julien.grall, jbeulich, zhaoshenglong,
	Roger Pau Monne



On 20/09/2016 01:19, "Boris Ostrovsky" <boris.ostrovsky@oracle.com> wrote:

>Some code (specifically, introduced by commit 801d469ad ("[HVM] ACPI
>support patch 3 of 4: ACPI _PRT table.")) has only been licensed under
>GPLv2. We want to prevent this code from showing up in non-GPL
>binaries which might become possible after we make ACPI builder code
>available to users other than hvmloader.
>
>There are two pieces that we need to be careful about:
>(1) A small piece of code in dsdt.asl that implements _PIC method
>(2) A fragment of ASL generator in mk_dsdt.c that describes PCI
>    interrupt routing.
>
>The cleanest way to deal with this seems to be taking generatedi ASL
>chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.

...

>diff --git a/tools/firmware/hvmloader/acpi/gpl/COPYING
>b/tools/firmware/hvmloader/acpi/gpl/COPYING
>new file mode 100644
>index 0000000..8dfdf61
>--- /dev/null
>+++ b/tools/firmware/hvmloader/acpi/gpl/COPYING
>@@ -0,0 +1,5 @@
>+Unlike files in the directory above that are licensed under GNU Lesser
>+General Public License version 2.1, files here are licensed under GNU
>+General Public License version 2.
>+
>+A copy of this license can be obtained at <http://www.gnu.org/licenses/>

Add the following:

INBOUND LICENSE

Contributions to this directory are made under the LGPLv2.1 *only* as
described
in the COPYING file of the parent directory. As LGPLv2.1 is compatible
with the
GPLv2, the resulting file is GPLv2 when seen as a whole.

The intention of this inbound license, is to avoid having to ask
subsequent 
contributors to this directory for permission to change the license from
GPLv2
to LGPLv2.1, once we get permission from the remaining copyright holders
of 
this directory to change the license to LGPLv2.1.

Note: The only outstanding permission required to re-license this
directory to
LGPLv2.1 is from Lenovo.


Regards
Lars


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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20 10:14   ` Ian Jackson
@ 2016-09-20 10:41     ` Lars Kurth
  2016-09-20 14:07     ` Boris Ostrovsky
  1 sibling, 0 replies; 59+ messages in thread
From: Lars Kurth @ 2016-09-20 10:41 UTC (permalink / raw)
  To: Ian Jackson, Boris Ostrovsky
  Cc: Wei Liu, Andrew Cooper, xen-devel, julien.grall, jbeulich,
	zhaoshenglong, Roger Pau Monne



On 20/09/2016 11:14, "Ian Jackson" <ian.jackson@eu.citrix.com> wrote:

>Boris Ostrovsky writes ("[PATCH v4 02/21] acpi: 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 under
>> GPLv2. We want to prevent this code from showing up in non-GPL
>> binaries which might become possible after we make ACPI builder code
>> available to users other than hvmloader.
>> 
>> There are two pieces that we need to be careful about:
>> (1) A small piece of code in dsdt.asl that implements _PIC method
>> (2) A fragment of ASL generator in mk_dsdt.c that describes PCI
>>     interrupt routing.
>> 
>> The cleanest way to deal with this seems to be taking generatedi ASL
>> chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
>
>This approach leaves us with the whole of dsdt.asl declared to be
>GPLv2.  If you are trying to relicence it as LGPLv2.1 this is not a
>good idea.
>
>Using this approach, if at some later point we get the missing ack
>from Lenovo, we would have to redo the licence review for the whole of
>dsdt.asl.  We would also have to ask Oracle's permission to relicense
>bits of the build system etc. !
>
>At the very least we should operate separate inbound/outbound
>licensing for this one file.

Boris was waiting for the appropriate text from me, which I sent to
this thread just before your reply came in. I proposed two parts
./COPYING and ./gpl/COPYING

>But as I wrote on IRC, I think it would also be best to split out
>_just the troublesome portions_ into their own files, and include them
>at build time.  That way we have file-by-file source licensing.

As mentioned on IRC, if that can be done, that would preferable.
Aka, we would have a LGPLv2.1 dsdt.asl, which then would include
the troublesome portions from ./gpl/ optionally when the library
is built for gpl.

Regards
Lars

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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20 10:14   ` Ian Jackson
  2016-09-20 10:41     ` Lars Kurth
@ 2016-09-20 14:07     ` Boris Ostrovsky
  2016-09-20 14:19       ` Ian Jackson
  1 sibling, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20 14:07 UTC (permalink / raw)
  To: Ian Jackson
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On 09/20/2016 06:14 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("[PATCH v4 02/21] acpi: 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 under
>> GPLv2. We want to prevent this code from showing up in non-GPL
>> binaries which might become possible after we make ACPI builder code
>> available to users other than hvmloader.
>>
>> There are two pieces that we need to be careful about:
>> (1) A small piece of code in dsdt.asl that implements _PIC method
>> (2) A fragment of ASL generator in mk_dsdt.c that describes PCI
>>     interrupt routing.
>>
>> The cleanest way to deal with this seems to be taking generatedi ASL
>> chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
> This approach leaves us with the whole of dsdt.asl declared to be
> GPLv2.  If you are trying to relicence it as LGPLv2.1 this is not a
> good idea.
>
> Using this approach, if at some later point we get the missing ack
> from Lenovo, we would have to redo the licence review for the whole of
> dsdt.asl.  We would also have to ask Oracle's permission to relicense
> bits of the build system etc. !
>
> At the very least we should operate separate inbound/outbound
> licensing for this one file.
>
> But as I wrote on IRC, I think it would also be best to split out
> _just the troublesome portions_ into their own files, and include them
> at build time.  That way we have file-by-file source licensing.

I must have misunderstood you then, I thought we were talking only about
excising code from mk_dsdt.c.

But yes, I can split dsdt.asl as well. Should we keep _S5 definition as
GPL-only?

Lenovo patch was

+/* Poweroff support - ties in with qemu emulation */

+    Name (\_S5, Package (0x04)
+    {
+        0x07,
+        0x07,
+        0x00,
+        0x00
+    })


and now it looks like

    /* _S3 and _S4 are in separate SSDTs */
    Name (\_S5, Package (0x04)
    {
        0x00,  /* PM1a_CNT.SLP_TYP */
        0x00,  /* PM1b_CNT.SLP_TYP */
        0x00,  /* reserved */
        0x00   /* reserved */
    })

My opinion is that using 0x7 would have been the original contribution
as the rest is is simply codifying what ACPI spec says. And since 0x7 is
no longer used we can re-license it together with the rest of dsdt.asl.


-boris


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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20 14:07     ` Boris Ostrovsky
@ 2016-09-20 14:19       ` Ian Jackson
  2016-09-20 14:58         ` Boris Ostrovsky
  0 siblings, 1 reply; 59+ messages in thread
From: Ian Jackson @ 2016-09-20 14:19 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

Boris Ostrovsky writes ("Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
> But yes, I can split dsdt.asl as well. Should we keep _S5 definition as
> GPL-only?

I think once we're going down this route there is no benefit in trying
to argue for individual bits of code-that-was-once-Lenovo's that there
is no copyright interest.

So I would split those lines out as well.  That will mean multiple
includes.

Does iasl have a suitable conditional include syntax or are you going
to use `cat' or something in the Makefile ?

Ian.

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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20 14:19       ` Ian Jackson
@ 2016-09-20 14:58         ` Boris Ostrovsky
  0 siblings, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-20 14:58 UTC (permalink / raw)
  To: Ian Jackson
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau


[-- Attachment #1.1.1: Type: text/plain, Size: 988 bytes --]

On 09/20/2016 10:19 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
>> But yes, I can split dsdt.asl as well. Should we keep _S5 definition as
>> GPL-only?
> I think once we're going down this route there is no benefit in trying
> to argue for individual bits of code-that-was-once-Lenovo's that there
> is no copyright interest.
>
> So I would split those lines out as well.  That will mean multiple
> includes.
>
> Does iasl have a suitable conditional include syntax or are you going
> to use `cat' or something in the Makefile ?


iasl has -I<path> option but I don't see a conditional. (And I have very
vague understanding of ASL syntax in case there is something that can be
done in the language itself).

I ran a quick test with 'cat' and it seems to work OK. Besides, we are
already using 'cat' implicitly: we append mk_dsdt output to existing
*asl file.


-boris


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

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

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

* Re: [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file
  2016-09-20  0:19 ` [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file Boris Ostrovsky
@ 2016-09-21 10:29   ` Jan Beulich
  2016-09-21 13:21     ` Boris Ostrovsky
  0 siblings, 1 reply; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 10:29 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> --- a/tools/firmware/hvmloader/acpi/Makefile
> +++ b/tools/firmware/hvmloader/acpi/Makefile
> @@ -33,13 +33,15 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
>  mk_dsdt: mk_dsdt.c
>  	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
>  
> -dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
> +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'
> -dsdt_%cpu.asl: dsdt.asl mk_dsdt
> +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 $*  >> $@

Comments I made on an earlier version now apply here too: In
order to properly deal with make interruptions or failures, this
output redirection should be replaced by going through a
temporary file. Presumably you still have this somewhere later
in the series (as it iirc was in v3), but imo that should then really
be moved ahead of the patch here.

Everything else looks fine.

Jan


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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-20  0:19 ` [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries Boris Ostrovsky
  2016-09-20 10:14   ` Ian Jackson
  2016-09-20 10:32   ` Lars Kurth
@ 2016-09-21 10:39   ` Jan Beulich
  2016-09-21 13:34     ` Boris Ostrovsky
  2 siblings, 1 reply; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 10:39 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, ian.jackson, xen-devel,
	julien.grall, zhaoshenglong, roger.pau

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> --- a/tools/firmware/hvmloader/acpi/dsdt.asl
> +++ /dev/null

Please try to represent this as a move, not as a delete+create.

> +    Scope ( \_SB.PCI0 )
> +    {
> +        Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
> +        Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )
> +        CreateWordField ( BUFB, 0x01, IRQV )
> +        Device ( LNKA ) {
> +            Name ( _HID,  EISAID("PNP0C0F") )
> +            Name ( _UID, 1 )
> +            Method ( _STA, 0 ) {
> +                If ( And(PIRA, 0x80) ) {
> +                    Return ( 0x09 )
> +                }
> +                Else {
> +                    Return ( 0x0B )
> +                }
> +            }
> +            Method ( _PRS ) {
> +                Return ( BUFA )
> +            }
> +            Method ( _DIS ) {
> +                Or ( PIRA, 0x80, PIRA )
> +            }
> +            Method ( _CRS ) {
> +                And ( PIRA, 0x0f, Local0 )
> +                ShiftLeft ( 0x1, Local0, IRQV )
> +                Return ( BUFB )
> +            }
> +            Method ( _SRS, 1 ) {
> +                CreateWordField ( ARG0, 0x01, IRQ1 )
> +                FindSetRightBit ( IRQ1, Local0 )
> +                Decrement ( Local0 )
> +                Store ( Local0, PIRA )
> +            }
> +        }
> +        Device ( LNKB ) {
>[...]
> +        Name(PRTP, Package()
> +        {
> +                Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0},
> +                Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0},
> +                Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0},
> +                Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0},
> +                Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0},
>[...]
> +                Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0},
> +        })
> +
> +        Name(PRTA, Package()
> +        {
> +                Package(){0x0001ffff, 0, 0, 20},
> +                Package(){0x0001ffff, 1, 0, 21},
> +                Package(){0x0001ffff, 2, 0, 22},
> +                Package(){0x0001ffff, 3, 0, 23},
> +                Package(){0x0002ffff, 0, 0, 24},
>[...]
> +                Package(){0x001fffff, 3, 0, 18},
> +        })
> +    }
> +}

I realize this is the easiest route, but how the various hard coded
numbers got generated would be completely lost, making it
extremely hard to make any changes here down the road. I
wonder whether the Makefile / output redirection approach couldn't
be easily extended to create all that data via a shell script fragment,
if retaining the C source (moved to a separate file) is indeed not an
option.

Nor would I think that would qualify here as someone having
produced the replacement code without having looked at the
original, as was suggested as a criteria before.

Jan


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

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

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

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> --- a/tools/firmware/hvmloader/util.h
> +++ b/tools/firmware/hvmloader/util.h
> @@ -47,7 +47,7 @@ void __bug(char *file, int line) __attribute__((noreturn));
>  #define max_t(type,x,y) \
>          ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
>  
> -static inline int test_bit(unsigned int b, void *p)
> +static inline int test_bit(unsigned int b, const void *p)
>  {
>      return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));

But then please also avoid casting away constness here. With that
corrected,
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-20  0:19 ` [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly Boris Ostrovsky
@ 2016-09-21 10:52   ` Jan Beulich
  2016-09-21 11:29     ` Ian Jackson
  2016-09-21 21:03     ` Boris Ostrovsky
  0 siblings, 2 replies; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 10:52 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> --- a/.gitignore
> +++ b/.gitignore
> @@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt
>  tools/firmware/etherboot/gpxe/*
>  tools/firmware/extboot/extboot.img
>  tools/firmware/extboot/signrom
> -tools/firmware/hvmloader/acpi/mk_dsdt
> -tools/firmware/hvmloader/acpi/dsdt*.c
> -tools/firmware/hvmloader/acpi/dsdt_*cpu*.asl
> -tools/firmware/hvmloader/acpi/ssdt_*.h
> +tools/firmware/hvmloader/dsdt*.c
> +tools/firmware/hvmloader/dsdt_*.asl

Aren't you wrongly dropping the *cpu part here?

> --- a/tools/firmware/hvmloader/acpi/Makefile
> +++ b/tools/firmware/hvmloader/acpi/Makefile
> @@ -15,41 +15,45 @@
>  XEN_ROOT = $(CURDIR)/../../../..
>  include $(XEN_ROOT)/tools/firmware/Rules.mk
>  
> -C_SRC-$(GPL) 	= build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
> -C_SRC		= build.c static_tables.c $(C_SRC-y)
> -OBJS  = $(patsubst %.c,%.o,$(C_SRC))
> +# Used as a workaround for a bug in some older iasl versions where
> +# the tool will ignore everything after last '.' in the path ('-p' argument)
> +TMP_SUFFIX	= tmp__

Hmm, the comment leaves open what newer iasl does? I suppose it
strips everything after the last . too, but only if that ones comes
after the last path separator? It took me a moment to understand
that no file with this suffix will ever be created, if my above summary
is right. Please clarify this in the comment.

With these two minor issues addressed,
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan


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

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

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

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> In prepearation to moving acpi sources into generally available
> libacpi:
> 
> 1. Pass IOAPIC/LAPIC/PCI mask values via struct acpi_config
> 2. Modify include files search paths to point to acpi directory
> 3. Macro-ise include file for build.c that defines various
>    utilities used by that file. Users of libacpi will be expected
>    to define this macro when compiling build.c
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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


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

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

* Re: [PATCH v4 14/21] libacpi: Build DSDT for PVH guests
  2016-09-20  0:19 ` [PATCH v4 14/21] libacpi: Build DSDT for PVH guests Boris Ostrovsky
@ 2016-09-21 11:27   ` Jan Beulich
  0 siblings, 0 replies; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 11:27 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> PVH guests require DSDT with only ACPI INFO (Xen-specific) and Processor
> objects. We separate ASL's ACPI INFO definition into dsdt_acpi_info.asl so
> that it can be included in ASLs for both HVM and PVH2.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 10:52   ` Jan Beulich
@ 2016-09-21 11:29     ` Ian Jackson
  2016-09-21 11:36       ` Jan Beulich
  2016-09-21 21:03     ` Boris Ostrovsky
  1 sibling, 1 reply; 59+ messages in thread
From: Ian Jackson @ 2016-09-21 11:29 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, zhaoshenglong,
	Boris Ostrovsky, roger.pau

Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> > --- a/tools/firmware/hvmloader/acpi/Makefile
> > +++ b/tools/firmware/hvmloader/acpi/Makefile
> > @@ -15,41 +15,45 @@
> >  XEN_ROOT = $(CURDIR)/../../../..
> >  include $(XEN_ROOT)/tools/firmware/Rules.mk
> >  
> > -C_SRC-$(GPL) 	= build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
> > -C_SRC		= build.c static_tables.c $(C_SRC-y)
> > -OBJS  = $(patsubst %.c,%.o,$(C_SRC))
> > +# Used as a workaround for a bug in some older iasl versions where
> > +# the tool will ignore everything after last '.' in the path ('-p' argument)
> > +TMP_SUFFIX	= tmp__
> 
> Hmm, the comment leaves open what newer iasl does? I suppose it
> strips everything after the last . too, but only if that ones comes
> after the last path separator?

I think Boris's approach ensures that the last . always comes after
the last path separator.

> It took me a moment to understand
> that no file with this suffix will ever be created, if my above summary
> is right. Please clarify this in the comment.

I'm not sure it's really helpful to put this TMP_SUFFIX thing in a
make variable but maybe Jan prefers it that way.

In any case I think the choice of `tmp__' is rather odd.  AFAICT the
resulting iasl command lines look like this:

  iasl -vs -p /path/to/here/blah.tmp__ -tc /path/to/here/blah.asl

I think `.dummy' would be a better string, if indeed it's a string
which we expect always to be stripped, and not to appear in any
filenames.

ian.

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

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

* Re: [PATCH v4 19/21] ilibxl: Initialize domain build info before calling libxl__domain_make
  2016-09-20  0:19 ` [PATCH v4 19/21] ilibxl: Initialize domain build info before calling libxl__domain_make Boris Ostrovsky
@ 2016-09-21 11:29   ` Jan Beulich
  0 siblings, 0 replies; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 11:29 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:

Btw - mind dropping the odd leading i from the subject?

Jan


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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-20  0:19 ` [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests Boris Ostrovsky
@ 2016-09-21 11:33   ` Jan Beulich
  2016-09-21 15:09     ` Boris Ostrovsky
  2016-09-22 10:53   ` Wei Liu
  1 sibling, 1 reply; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 11:33 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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


> --- a/tools/libacpi/build.c
> +++ b/tools/libacpi/build.c
> @@ -20,6 +20,7 @@
>  #include "ssdt_s4.h"
>  #include "ssdt_tpm.h"
>  #include "ssdt_pm.h"
> +#include <xen/hvm/hvm_info_table.h>

... I don't really see why this becomes necessary here. Please
clarify.

Jan


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 11:29     ` Ian Jackson
@ 2016-09-21 11:36       ` Jan Beulich
  2016-09-21 11:38         ` Ian Jackson
  0 siblings, 1 reply; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 11:36 UTC (permalink / raw)
  To: Ian Jackson
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, zhaoshenglong,
	Boris Ostrovsky, roger.pau

>>> On 21.09.16 at 13:29, <ian.jackson@eu.citrix.com> wrote:
> Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object 
> files directly"):
>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>> > --- a/tools/firmware/hvmloader/acpi/Makefile
>> > +++ b/tools/firmware/hvmloader/acpi/Makefile
>> > @@ -15,41 +15,45 @@
>> >  XEN_ROOT = $(CURDIR)/../../../..
>> >  include $(XEN_ROOT)/tools/firmware/Rules.mk
>> >  
>> > -C_SRC-$(GPL) 	= build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
>> > -C_SRC		= build.c static_tables.c $(C_SRC-y)
>> > -OBJS  = $(patsubst %.c,%.o,$(C_SRC))
>> > +# Used as a workaround for a bug in some older iasl versions where
>> > +# the tool will ignore everything after last '.' in the path ('-p' argument)
>> > +TMP_SUFFIX	= tmp__
>> 
>> Hmm, the comment leaves open what newer iasl does? I suppose it
>> strips everything after the last . too, but only if that ones comes
>> after the last path separator?
> 
> I think Boris's approach ensures that the last . always comes after
> the last path separator.
> 
>> It took me a moment to understand
>> that no file with this suffix will ever be created, if my above summary
>> is right. Please clarify this in the comment.
> 
> I'm not sure it's really helpful to put this TMP_SUFFIX thing in a
> make variable but maybe Jan prefers it that way.

At least I didn't ask for it, and I'd be fine without.

> In any case I think the choice of `tmp__' is rather odd.  AFAICT the
> resulting iasl command lines look like this:
> 
>   iasl -vs -p /path/to/here/blah.tmp__ -tc /path/to/here/blah.asl
> 
> I think `.dummy' would be a better string, if indeed it's a string
> which we expect always to be stripped, and not to appear in any
> filenames.

Another (currently later, but I'd prefer it to be moved ahead)
patch uses this for actual temporary files.

Jan


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 11:36       ` Jan Beulich
@ 2016-09-21 11:38         ` Ian Jackson
  2016-09-21 11:40           ` Jan Beulich
  0 siblings, 1 reply; 59+ messages in thread
From: Ian Jackson @ 2016-09-21 11:38 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, zhaoshenglong,
	Boris Ostrovsky, roger.pau

Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
> On 21.09.16 at 13:29, <ian.jackson@eu.citrix.com> wrote:
> > I think `.dummy' would be a better string, if indeed it's a string
> > which we expect always to be stripped, and not to appear in any
> > filenames.
> 
> Another (currently later, but I'd prefer it to be moved ahead)
> patch uses this for actual temporary files.

OK, then I don't understand what's wrong with ".tmp" ...

Ian.

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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 11:38         ` Ian Jackson
@ 2016-09-21 11:40           ` Jan Beulich
  2016-09-21 13:45             ` Boris Ostrovsky
  0 siblings, 1 reply; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 11:40 UTC (permalink / raw)
  To: Ian Jackson, Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, zhaoshenglong,
	roger.pau

>>> On 21.09.16 at 13:38, <ian.jackson@eu.citrix.com> wrote:
> Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object 
> files directly"):
>> On 21.09.16 at 13:29, <ian.jackson@eu.citrix.com> wrote:
>> > I think `.dummy' would be a better string, if indeed it's a string
>> > which we expect always to be stripped, and not to appear in any
>> > filenames.
>> 
>> Another (currently later, but I'd prefer it to be moved ahead)
>> patch uses this for actual temporary files.
> 
> OK, then I don't understand what's wrong with ".tmp" ...

So did I think when looking at the patch, but then I also thought
(at least until I saw that actual files get created with that suffix)
that it doesn't really matter. Boris?

Jan


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

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

* Re: [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file
  2016-09-21 10:29   ` Jan Beulich
@ 2016-09-21 13:21     ` Boris Ostrovsky
  0 siblings, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-21 13:21 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/21/2016 06:29 AM, Jan Beulich wrote:
>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>> --- a/tools/firmware/hvmloader/acpi/Makefile
>> +++ b/tools/firmware/hvmloader/acpi/Makefile
>> @@ -33,13 +33,15 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
>>  mk_dsdt: mk_dsdt.c
>>  	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
>>  
>> -dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
>> +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'
>> -dsdt_%cpu.asl: dsdt.asl mk_dsdt
>> +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 $*  >> $@
> Comments I made on an earlier version now apply here too: In
> order to properly deal with make interruptions or failures, this
> output redirection should be replaced by going through a
> temporary file. Presumably you still have this somewhere later
> in the series (as it iirc was in v3), but imo that should then really
> be moved ahead of the patch here.


Since it looks like I will need to update this Makefile anyway I can
move that patch (#15) to be the first.

-boris

>
> Everything else looks fine.
>
> Jan
>



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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-21 10:39   ` Jan Beulich
@ 2016-09-21 13:34     ` Boris Ostrovsky
  2016-09-21 13:47       ` Jan Beulich
  0 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-21 13:34 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, ian.jackson, xen-devel,
	julien.grall, zhaoshenglong, roger.pau

On 09/21/2016 06:39 AM, Jan Beulich wrote:
>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>> --- a/tools/firmware/hvmloader/acpi/dsdt.asl
>> +++ /dev/null
> Please try to represent this as a move, not as a delete+create.

This was done by 'git mv' and patches were generated with 'git
format-patch -M5 ...' so I am not sure how I can convince git to show it
as a rename. Maybe increase the argument to -M to something higher?


>
>> +    Scope ( \_SB.PCI0 )
>> +    {
>> +        Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
>> +        Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )
>> +        CreateWordField ( BUFB, 0x01, IRQV )
>> +        Device ( LNKA ) {
>> +            Name ( _HID,  EISAID("PNP0C0F") )
>> +            Name ( _UID, 1 )
>> +            Method ( _STA, 0 ) {
>> +                If ( And(PIRA, 0x80) ) {
>> +                    Return ( 0x09 )
>> +                }
>> +                Else {
>> +                    Return ( 0x0B )
>> +                }
>> +            }
>> +            Method ( _PRS ) {
>> +                Return ( BUFA )
>> +            }
>> +            Method ( _DIS ) {
>> +                Or ( PIRA, 0x80, PIRA )
>> +            }
>> +            Method ( _CRS ) {
>> +                And ( PIRA, 0x0f, Local0 )
>> +                ShiftLeft ( 0x1, Local0, IRQV )
>> +                Return ( BUFB )
>> +            }
>> +            Method ( _SRS, 1 ) {
>> +                CreateWordField ( ARG0, 0x01, IRQ1 )
>> +                FindSetRightBit ( IRQ1, Local0 )
>> +                Decrement ( Local0 )
>> +                Store ( Local0, PIRA )
>> +            }
>> +        }
>> +        Device ( LNKB ) {
>> [...]
>> +        Name(PRTP, Package()
>> +        {
>> +                Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0},
>> +                Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0},
>> +                Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0},
>> +                Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0},
>> +                Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0},
>> [...]
>> +                Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0},
>> +        })
>> +
>> +        Name(PRTA, Package()
>> +        {
>> +                Package(){0x0001ffff, 0, 0, 20},
>> +                Package(){0x0001ffff, 1, 0, 21},
>> +                Package(){0x0001ffff, 2, 0, 22},
>> +                Package(){0x0001ffff, 3, 0, 23},
>> +                Package(){0x0002ffff, 0, 0, 24},
>> [...]
>> +                Package(){0x001fffff, 3, 0, 18},
>> +        })
>> +    }
>> +}
> I realize this is the easiest route, but how the various hard coded
> numbers got generated would be completely lost, making it
> extremely hard to make any changes here down the road. I
> wonder whether the Makefile / output redirection approach couldn't
> be easily extended to create all that data via a shell script fragment,
> if retaining the C source (moved to a separate file) is indeed not an
> option.
>
> Nor would I think that would qualify here as someone having
> produced the replacement code without having looked at the
> original, as was suggested as a criteria before.

I can do that (but then I think it would also make sense to have it
generate _S5 and _PIC methods as well, even though they are "static").

I think bash script would be better than C since we mostly care about
loops that generate values and not language constructs such as stmt()
and push_blk().

-boris



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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 11:40           ` Jan Beulich
@ 2016-09-21 13:45             ` Boris Ostrovsky
  2016-09-21 15:05               ` Ian Jackson
  0 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-21 13:45 UTC (permalink / raw)
  To: Jan Beulich, Ian Jackson
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, zhaoshenglong,
	roger.pau

On 09/21/2016 07:40 AM, Jan Beulich wrote:
>>>> On 21.09.16 at 13:38, <ian.jackson@eu.citrix.com> wrote:
>> Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object 
>> files directly"):
>>> On 21.09.16 at 13:29, <ian.jackson@eu.citrix.com> wrote:
>>>> I think `.dummy' would be a better string, if indeed it's a string
>>>> which we expect always to be stripped, and not to appear in any
>>>> filenames.
>>> Another (currently later, but I'd prefer it to be moved ahead)
>>> patch uses this for actual temporary files.
>> OK, then I don't understand what's wrong with ".tmp" ...
> So did I think when looking at the patch, but then I also thought
> (at least until I saw that actual files get created with that suffix)
> that it doesn't really matter. Boris?

I think there are two questions about using TMP_SUFFIX=tmp__

1. It is indeed used for two purposes --- one is to work around the bug
and the other is to append to intermediate build files (that are later
removed). There are two instances where I need to handle the bug and
thus I use a variable and not a literal ".dummy". And since I already
have (or, in this iteration of the series, will have in the later patch)
TMP_SUFFIX I figured I'd use it here as well.

2. ".tmp__" vs ".tmp": Because the temporary files are generated not in
tools/libacpi but in the directory of the libacpi user (such as libxl)
it is possible that a Makefile there might use ".tmp' for its own
purposes so I am trying here to minimize chances of a conflict. Maybe
even ".tmp_acpi"?

-boris


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

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

* Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
  2016-09-21 13:34     ` Boris Ostrovsky
@ 2016-09-21 13:47       ` Jan Beulich
  0 siblings, 0 replies; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 13:47 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Lars Kurth, wei.liu2, andrew.cooper3, ian.jackson, xen-devel,
	julien.grall, zhaoshenglong, roger.pau

>>> On 21.09.16 at 15:34, <boris.ostrovsky@oracle.com> wrote:
> On 09/21/2016 06:39 AM, Jan Beulich wrote:
>>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>>> --- a/tools/firmware/hvmloader/acpi/dsdt.asl
>>> +++ /dev/null
>> Please try to represent this as a move, not as a delete+create.
> 
> This was done by 'git mv' and patches were generated with 'git
> format-patch -M5 ...' so I am not sure how I can convince git to show it
> as a rename. Maybe increase the argument to -M to something higher?

Or perhaps with the other adjustment carried out, the delta will
become small enough.

>>> +    Scope ( \_SB.PCI0 )
>>> +    {
>>> +        Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
>>> +        Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )
>>> +        CreateWordField ( BUFB, 0x01, IRQV )
>>> +        Device ( LNKA ) {
>>> +            Name ( _HID,  EISAID("PNP0C0F") )
>>> +            Name ( _UID, 1 )
>>> +            Method ( _STA, 0 ) {
>>> +                If ( And(PIRA, 0x80) ) {
>>> +                    Return ( 0x09 )
>>> +                }
>>> +                Else {
>>> +                    Return ( 0x0B )
>>> +                }
>>> +            }
>>> +            Method ( _PRS ) {
>>> +                Return ( BUFA )
>>> +            }
>>> +            Method ( _DIS ) {
>>> +                Or ( PIRA, 0x80, PIRA )
>>> +            }
>>> +            Method ( _CRS ) {
>>> +                And ( PIRA, 0x0f, Local0 )
>>> +                ShiftLeft ( 0x1, Local0, IRQV )
>>> +                Return ( BUFB )
>>> +            }
>>> +            Method ( _SRS, 1 ) {
>>> +                CreateWordField ( ARG0, 0x01, IRQ1 )
>>> +                FindSetRightBit ( IRQ1, Local0 )
>>> +                Decrement ( Local0 )
>>> +                Store ( Local0, PIRA )
>>> +            }
>>> +        }
>>> +        Device ( LNKB ) {
>>> [...]
>>> +        Name(PRTP, Package()
>>> +        {
>>> +                Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0},
>>> +                Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0},
>>> +                Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0},
>>> +                Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0},
>>> +                Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0},
>>> [...]
>>> +                Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0},
>>> +        })
>>> +
>>> +        Name(PRTA, Package()
>>> +        {
>>> +                Package(){0x0001ffff, 0, 0, 20},
>>> +                Package(){0x0001ffff, 1, 0, 21},
>>> +                Package(){0x0001ffff, 2, 0, 22},
>>> +                Package(){0x0001ffff, 3, 0, 23},
>>> +                Package(){0x0002ffff, 0, 0, 24},
>>> [...]
>>> +                Package(){0x001fffff, 3, 0, 18},
>>> +        })
>>> +    }
>>> +}
>> I realize this is the easiest route, but how the various hard coded
>> numbers got generated would be completely lost, making it
>> extremely hard to make any changes here down the road. I
>> wonder whether the Makefile / output redirection approach couldn't
>> be easily extended to create all that data via a shell script fragment,
>> if retaining the C source (moved to a separate file) is indeed not an
>> option.
>>
>> Nor would I think that would qualify here as someone having
>> produced the replacement code without having looked at the
>> original, as was suggested as a criteria before.
> 
> I can do that (but then I think it would also make sense to have it
> generate _S5 and _PIC methods as well, even though they are "static").

Sounds reasonable.

Jan


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 13:45             ` Boris Ostrovsky
@ 2016-09-21 15:05               ` Ian Jackson
  2016-09-21 15:21                 ` Boris Ostrovsky
  0 siblings, 1 reply; 59+ messages in thread
From: Ian Jackson @ 2016-09-21 15:05 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

Boris Ostrovsky writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
> 2. ".tmp__" vs ".tmp": Because the temporary files are generated not in
> tools/libacpi but in the directory of the libacpi user (such as libxl)
> it is possible that a Makefile there might use ".tmp' for its own
> purposes so I am trying here to minimize chances of a conflict. Maybe
> even ".tmp_acpi"?

Wait, the libxl makefiles are going to end up running iasl ?

If you end up making these files appear elsewhere then I think ".tmp"
is fine if the first part of the filename is unique enough.

Ian.

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

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

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

On 09/21/2016 07:33 AM, Jan Beulich wrote:
>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> libacpi parts
> Acked-by: Jan Beulich <jbeulich@suse.com>
> albeit ...
>
>
>> --- a/tools/libacpi/build.c
>> +++ b/tools/libacpi/build.c
>> @@ -20,6 +20,7 @@
>>  #include "ssdt_s4.h"
>>  #include "ssdt_tpm.h"
>>  #include "ssdt_pm.h"
>> +#include <xen/hvm/hvm_info_table.h>
> ... I don't really see why this becomes necessary here. Please
> clarify.

xen/hvm/hvm_info_table.h in included by hvmloader/util.h so we haven't
needed this include until now.


-boris

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

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

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

>>> On 21.09.16 at 17:09, <boris.ostrovsky@oracle.com> wrote:
> On 09/21/2016 07:33 AM, Jan Beulich wrote:
>>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>>> --- a/tools/libacpi/build.c
>>> +++ b/tools/libacpi/build.c
>>> @@ -20,6 +20,7 @@
>>>  #include "ssdt_s4.h"
>>>  #include "ssdt_tpm.h"
>>>  #include "ssdt_pm.h"
>>> +#include <xen/hvm/hvm_info_table.h>
>> ... I don't really see why this becomes necessary here. Please
>> clarify.
> 
> xen/hvm/hvm_info_table.h in included by hvmloader/util.h so we haven't
> needed this include until now.

But you're not removing any inclusion here. Does that addition
perhaps belong elsewhere?

Jan


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 15:05               ` Ian Jackson
@ 2016-09-21 15:21                 ` Boris Ostrovsky
  2016-09-21 15:25                   ` Ian Jackson
  0 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-21 15:21 UTC (permalink / raw)
  To: Ian Jackson
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

On 09/21/2016 11:05 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
>> 2. ".tmp__" vs ".tmp": Because the temporary files are generated not in
>> tools/libacpi but in the directory of the libacpi user (such as libxl)
>> it is possible that a Makefile there might use ".tmp' for its own
>> purposes so I am trying here to minimize chances of a conflict. Maybe
>> even ".tmp_acpi"?
> Wait, the libxl makefiles are going to end up running iasl ?

Not directly. There is a new target in libxl's Makefile:

acpi:
        $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)

(ACPI_PATH is tools/libacpi)

>
> If you end up making these files appear elsewhere then I think ".tmp"
> is fine if the first part of the filename is unique enough.

They are built in libxl directory, this is by design. If we were to
build them in tools/libacpi then we may collide with other components
(such as hvmloader) doing the build at the same time.

Keeping them in /tmp/`mktemp -d`, for example, does not quite work since
we can't easily clean this up in case of an interrupt. (I tried this in
an earlier version and it doesn't look good).

But the names are pretty unique (dsdt_<blah> or <ssdt_blah>).

-boris


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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 15:21                 ` Boris Ostrovsky
@ 2016-09-21 15:25                   ` Ian Jackson
  0 siblings, 0 replies; 59+ messages in thread
From: Ian Jackson @ 2016-09-21 15:25 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, xen-devel, julien.grall, Jan Beulich,
	zhaoshenglong, roger.pau

Boris Ostrovsky writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
> On 09/21/2016 11:05 AM, Ian Jackson wrote:
> > Wait, the libxl makefiles are going to end up running iasl ?
> 
> Not directly. There is a new target in libxl's Makefile:
> 
> acpi:
>         $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
> 
> (ACPI_PATH is tools/libacpi)

Right.

> > If you end up making these files appear elsewhere then I think ".tmp"
> > is fine if the first part of the filename is unique enough.
> 
> They are built in libxl directory, this is by design. If we were to
> build them in tools/libacpi then we may collide with other components
> (such as hvmloader) doing the build at the same time.

I see.  Yes, this is a good approach.

> Keeping them in /tmp/`mktemp -d`, for example, does not quite work since
> we can't easily clean this up in case of an interrupt. (I tried this in
> an earlier version and it doesn't look good).

What you have now is better.

> But the names are pretty unique (dsdt_<blah> or <ssdt_blah>).

That's good.

Thanks,
Ian.

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

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

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

On 09/21/2016 11:16 AM, Jan Beulich wrote:
>>>> On 21.09.16 at 17:09, <boris.ostrovsky@oracle.com> wrote:
>> On 09/21/2016 07:33 AM, Jan Beulich wrote:
>>>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>>>> --- a/tools/libacpi/build.c
>>>> +++ b/tools/libacpi/build.c
>>>> @@ -20,6 +20,7 @@
>>>>  #include "ssdt_s4.h"
>>>>  #include "ssdt_tpm.h"
>>>>  #include "ssdt_pm.h"
>>>> +#include <xen/hvm/hvm_info_table.h>
>>> ... I don't really see why this becomes necessary here. Please
>>> clarify.
>> xen/hvm/hvm_info_table.h in included by hvmloader/util.h so we haven't
>> needed this include until now.
> But you're not removing any inclusion here. Does that addition
> perhaps belong elsewhere?

I suppose I can add it to libxl_x86_acpi.h (and remove from
libxl_x86_acpi.c) to be consistent with how it is included by util.h

OTOH, include files that we pass as
-DLIBACPI_STDUTILS=\"$(CURDIR)/<includefile.h.> are intended to provide
declarations for things that are specific to the caller, not to Xen in
general.

-boris


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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-21 15:34         ` Boris Ostrovsky
@ 2016-09-21 16:02           ` Jan Beulich
  2016-09-21 16:38             ` Boris Ostrovsky
  0 siblings, 1 reply; 59+ messages in thread
From: Jan Beulich @ 2016-09-21 16:02 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 21.09.16 at 17:34, <boris.ostrovsky@oracle.com> wrote:
> On 09/21/2016 11:16 AM, Jan Beulich wrote:
>>>>> On 21.09.16 at 17:09, <boris.ostrovsky@oracle.com> wrote:
>>> On 09/21/2016 07:33 AM, Jan Beulich wrote:
>>>>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>>>>> --- a/tools/libacpi/build.c
>>>>> +++ b/tools/libacpi/build.c
>>>>> @@ -20,6 +20,7 @@
>>>>>  #include "ssdt_s4.h"
>>>>>  #include "ssdt_tpm.h"
>>>>>  #include "ssdt_pm.h"
>>>>> +#include <xen/hvm/hvm_info_table.h>
>>>> ... I don't really see why this becomes necessary here. Please
>>>> clarify.
>>> xen/hvm/hvm_info_table.h in included by hvmloader/util.h so we haven't
>>> needed this include until now.
>> But you're not removing any inclusion here. Does that addition
>> perhaps belong elsewhere?
> 
> I suppose I can add it to libxl_x86_acpi.h (and remove from
> libxl_x86_acpi.c) to be consistent with how it is included by util.h

That doesn't answer my question (by "elsewhere" I meant
another, earlier patch). By the time stuff got moved to tools/
you can't possibly rely on util.h inclusion here anymore.

Jan


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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-21 16:02           ` Jan Beulich
@ 2016-09-21 16:38             ` Boris Ostrovsky
  2016-09-22  8:39               ` Jan Beulich
  0 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-21 16:38 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/21/2016 12:02 PM, Jan Beulich wrote:
>>>> On 21.09.16 at 17:34, <boris.ostrovsky@oracle.com> wrote:
>> On 09/21/2016 11:16 AM, Jan Beulich wrote:
>>>>>> On 21.09.16 at 17:09, <boris.ostrovsky@oracle.com> wrote:
>>>> On 09/21/2016 07:33 AM, Jan Beulich wrote:
>>>>>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>>>>>> --- a/tools/libacpi/build.c
>>>>>> +++ b/tools/libacpi/build.c
>>>>>> @@ -20,6 +20,7 @@
>>>>>>  #include "ssdt_s4.h"
>>>>>>  #include "ssdt_tpm.h"
>>>>>>  #include "ssdt_pm.h"
>>>>>> +#include <xen/hvm/hvm_info_table.h>
>>>>> ... I don't really see why this becomes necessary here. Please
>>>>> clarify.
>>>> xen/hvm/hvm_info_table.h in included by hvmloader/util.h so we haven't
>>>> needed this include until now.
>>> But you're not removing any inclusion here. Does that addition
>>> perhaps belong elsewhere?
>> I suppose I can add it to libxl_x86_acpi.h (and remove from
>> libxl_x86_acpi.c) to be consistent with how it is included by util.h
> That doesn't answer my question (by "elsewhere" I meant
> another, earlier patch). By the time stuff got moved to tools/
> you can't possibly rely on util.h inclusion here anymore.

Patch 11 ("acpi/hvmloader: Include file/paths adjustments") may be a
better place to make this change.

I don't understand though why we can't rely on util.h after the move.
hvmloader will continue including it via
-DLIBACPI_STDUTILS=\"$(CURDIR)/util.h. At that point (and until this
patch) hvmloader is the only user of libacpi and including
hvm_info_table.h via util.h works fine (but, as I said in the previous
message, is not logical).

-boris



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

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

* Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
  2016-09-21 10:52   ` Jan Beulich
  2016-09-21 11:29     ` Ian Jackson
@ 2016-09-21 21:03     ` Boris Ostrovsky
  1 sibling, 0 replies; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-21 21:03 UTC (permalink / raw)
  To: Jan Beulich
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

On 09/21/2016 06:52 AM, Jan Beulich wrote:
>>>> On 20.09.16 at 02:19, <boris.ostrovsky@oracle.com> wrote:
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt
>>  tools/firmware/etherboot/gpxe/*
>>  tools/firmware/extboot/extboot.img
>>  tools/firmware/extboot/signrom
>> -tools/firmware/hvmloader/acpi/mk_dsdt
>> -tools/firmware/hvmloader/acpi/dsdt*.c
>> -tools/firmware/hvmloader/acpi/dsdt_*cpu*.asl
>> -tools/firmware/hvmloader/acpi/ssdt_*.h
>> +tools/firmware/hvmloader/dsdt*.c
>> +tools/firmware/hvmloader/dsdt_*.asl
> Aren't you wrongly dropping the *cpu part here?

(Missed this)

No: *cpu* was added earlier to keep hvmloader/acpi/dsdt_acpi_info.asl
tracked by git but ignore generated files like
hvmloader/acpi/dsdt_anycpu.asl. With this patch, those generated files
will be created in hvmloader/ directory while dsdt_acpi_info.asl stays
in hvmloader/acpi/ (and will eventually be moved to tools/libacpi).

Come think of it, hvmloader/dsdt* and hvmloader/ssdt* should all be ignored.

-boris



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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-21 16:38             ` Boris Ostrovsky
@ 2016-09-22  8:39               ` Jan Beulich
  0 siblings, 0 replies; 59+ messages in thread
From: Jan Beulich @ 2016-09-22  8:39 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	zhaoshenglong, roger.pau

>>> On 21.09.16 at 18:38, <boris.ostrovsky@oracle.com> wrote:
> I don't understand though why we can't rely on util.h after the move.

Once you move the component, it should be self-contained.

Jan


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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-20  0:19 ` [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests Boris Ostrovsky
  2016-09-21 11:33   ` Jan Beulich
@ 2016-09-22 10:53   ` Wei Liu
  2016-09-22 15:57     ` Boris Ostrovsky
  1 sibling, 1 reply; 59+ messages in thread
From: Wei Liu @ 2016-09-22 10:53 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: wei.liu2, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Mon, Sep 19, 2016 at 08:19:38PM -0400, Boris Ostrovsky wrote:
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

The code mostly looks good.  Some nits below.

> ---
> Changes in v4:
> * Remove allocation-specific fields from struct acpi_ctxt and use
>   an enclosing struct libxl_acpi_ctxt.
> * Use private struct hvminfo (to deal with constified struct
>   acpi_config->hvminfo)
> 
>  .gitignore                   |  12 ++-
>  tools/libacpi/build.c        |   7 +-
>  tools/libacpi/libacpi.h      |   6 +-
>  tools/libxl/Makefile         |  18 +++-
>  tools/libxl/libxl_arch.h     |   3 +
>  tools/libxl/libxl_x86.c      |  30 ++++--
>  tools/libxl/libxl_x86_acpi.c | 243 +++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/libxl_x86_acpi.h |  35 +++++++
>  8 files changed, 334 insertions(+), 20 deletions(-)
>  create mode 100644 tools/libxl/libxl_x86_acpi.c
>  create mode 100644 tools/libxl/libxl_x86_acpi.h
> 
> diff --git a/.gitignore b/.gitignore
> index 5720e0f..9b6f58e 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -173,15 +173,19 @@ tools/include/xen/*
>  tools/include/xen-xsm/*
>  tools/include/xen-foreign/*.(c|h|size)
>  tools/include/xen-foreign/checker
> -tools/libxl/libxlu_cfg_y.output
> +tools/libxl/_libxl.api-for-check
> +tools/libxl/*.api-ok
>  tools/libxl/*.pc
>  tools/libxl/*.pc.in
> -tools/libxl/xl
> +tools/libxl/dsdt*.c
> +tools/libxl/dsdt_*.asl
> +tools/libxl/libxlu_cfg_y.output
> +tools/libxl/mk_dsdt
> +tools/libxl/ssdt_*.h
>  tools/libxl/testenum
>  tools/libxl/testenum.c
>  tools/libxl/tmp.*
> -tools/libxl/_libxl.api-for-check
> -tools/libxl/*.api-ok
> +tools/libxl/xl
>  tools/misc/cpuperf/cpuperf-perfcntr
>  tools/misc/cpuperf/cpuperf-xen
>  tools/misc/xc_shadow
> diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
> index 00fb67e..47dae01 100644
> --- a/tools/libacpi/build.c
> +++ b/tools/libacpi/build.c
> @@ -20,6 +20,7 @@
>  #include "ssdt_s4.h"
>  #include "ssdt_tpm.h"
>  #include "ssdt_pm.h"
> +#include <xen/hvm/hvm_info_table.h>
>  #include <xen/hvm/hvm_xs_strings.h>
>  #include <xen/hvm/params.h>
>  #include <xen/memory.h>
> @@ -496,7 +497,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;
> @@ -631,11 +632,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)
>      if ( !new_vm_gid(ctxt, config, acpi_info) )
>          goto oom;
>  
> -    return;
> +    return 0;
>  
>  oom:
>      printf("unable to build ACPI tables: out of memory\n");
> -
> +    return -1;
>  }
>  
>  /*
> diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h
> index e386362..1d388f9 100644
> --- a/tools/libacpi/libacpi.h
> +++ b/tools/libacpi/libacpi.h
> @@ -78,10 +78,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 */
>      uint8_t (*lapic_id)(unsigned cpu);
> @@ -91,7 +91,7 @@ struct acpi_config {
>      uint8_t ioapic_id;
>  };
>  
> -void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
> +int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config);
>  
>  #endif /* __LIBACPI_H__ */
>  
> diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
> index 90427ff..336358c 100644
> --- a/tools/libxl/Makefile
> +++ b/tools/libxl/Makefile
> @@ -75,7 +75,21 @@ else
>  LIBXL_OBJS-y += libxl_no_colo.o
>  endif
>  
> -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
> +ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
> +ACPI_FILES = dsdt_pvh.c
> +ACPI_OBJS  = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
> +$(ACPI_FILES): acpi
> +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
> +vpath build.c $(ACPI_PATH)/
> +vpath static_tables.c $(ACPI_PATH)/
> +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
> +
> +.PHONY: acpi
> +acpi:
> +	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
> +-include acpi

Useless include?

> +
> +LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
>  LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
>  
>  ifeq ($(CONFIG_NetBSD),y)
> @@ -167,6 +181,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
>  $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
>  
>  libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
> +libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
>  
>  SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
>  $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
> @@ -309,6 +324,7 @@ clean:
>  	$(RM) -f testidl.c.new testidl.c *.api-ok
>  	$(RM) -f xenlight.pc
>  	$(RM) -f xlutil.pc
> +	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
>  
>  distclean: clean
>  	$(RM) -f xenlight.pc.in xlutil.pc.in
> diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
> index 253a037..7a70b01 100644
> --- a/tools/libxl/libxl_arch.h
> +++ b/tools/libxl/libxl_arch.h
> @@ -66,6 +66,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
>  
>  #define LAPIC_BASE_ADDRESS  0xfee00000
>  
> +int libxl__dom_load_acpi(libxl__gc *gc,
> +			 const libxl_domain_build_info *b_info,
> +			 struct xc_dom_image *dom);

Use space instead of tab please.

>  #endif
>  
>  #endif
> diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
> index 2b221aa..d10b04b 100644
> --- a/tools/libxl/libxl_x86.c
> +++ b/tools/libxl/libxl_x86.c
> @@ -8,15 +8,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>                                        xc_domain_configuration_t *xc_config)
>  {
>  
> -    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
> -        d_config->b_info.device_model_version !=
> -        LIBXL_DEVICE_MODEL_VERSION_NONE) {
> -        /* HVM domains with a device model. */
> -        xc_config->emulation_flags = XEN_X86_EMU_ALL;
> -    } else {
> -        /* PV or HVM domains without a device model. */
> +    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) {
> +        if (d_config->b_info.device_model_version !=
> +            LIBXL_DEVICE_MODEL_VERSION_NONE) {
> +            xc_config->emulation_flags = XEN_X86_EMU_ALL;
> +        } else if (libxl_defbool_val(d_config->b_info.u.hvm.apic)) {
> +            /*
> +             * HVM guests without device model may want
> +             * to have LAPIC emulation.
> +             */
> +            xc_config->emulation_flags = XEN_X86_EMU_LAPIC;
> +        }
> +    } else 
>          xc_config->emulation_flags = 0;
> -    }
>  

Coding style nit: We now forbid an else branch without braces. Please
add them here.

>      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;

Use rc please.

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

Extraneous spaces here. And lift ret= bit out of if statement.

> +            LOGE(ERROR, "libxl_dom_load_acpi failed");
> +    }
> +
> +    return ret;
>  }
>  
>  /* Return 0 on success, ERROR_* on failure. */
> diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libxl/libxl_x86_acpi.c
> new file mode 100644
> index 0000000..1b38116
> --- /dev/null
> +++ b/tools/libxl/libxl_x86_acpi.c
> @@ -0,0 +1,243 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU Lesser General Public License as published
> + * by the Free Software Foundation; version 2.1 only. with the special
> + * exception on linking described in file LICENSE.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
> + */
> +
> +#include "libxl_internal.h"
> +#include "libxl_arch.h"
> +#include <xen/hvm/hvm_info_table.h>
> +#include <xen/hvm/e820.h>
> +#include "libacpi/libacpi.h"
> +
> +#include <xc_dom.h>
> +
> + /* Number of pages holding ACPI tables */
> +#define NUM_ACPI_PAGES 16
> +/* Store RSDP in the last 64 bytes of BIOS RO memory */
> +#define RSDP_ADDRESS (0x100000 - 64)
> +#define ACPI_INFO_PHYSICAL_ADDRESS 0xfc000000
> +
> +struct libxl_acpi_ctxt {
> +    struct acpi_ctxt c;
> +
> +    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;
> +};
> +
> +extern const unsigned char dsdt_pvh[];
> +extern const unsigned int dsdt_pvh_len;
> +
> +/* Assumes contiguous physical space */
> +static unsigned long virt_to_phys(struct acpi_ctxt *ctxt, void *v)
> +{
> +    struct libxl_acpi_ctxt *libxl_ctxt =
> +        CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c);
> +
> +    return (((unsigned long)v - libxl_ctxt->alloc_base_vaddr) +
> +            libxl_ctxt->alloc_base_paddr);
> +}
> +
> +static void *mem_alloc(struct acpi_ctxt *ctxt,
> +                       uint32_t size, uint32_t align)
> +{
> +    struct libxl_acpi_ctxt *libxl_ctxt =
> +        CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c);
> +    unsigned long s, e;
> +
> +    /* Align to at least 16 bytes. */
> +    if (align < 16)
> +        align = 16;
> +
> +    s = (libxl_ctxt->alloc_currp + align) & ~((unsigned long)align - 1);
> +    e = s + size - 1;
> +
> +    /* TODO: Reallocate memory */
> +    if ((e < s) || (e >= libxl_ctxt->alloc_end))
> +        return NULL;
> +
> +    while (libxl_ctxt->alloc_currp >> libxl_ctxt->page_shift != 
> +           e >> libxl_ctxt->page_shift)
> +        libxl_ctxt->alloc_currp += libxl_ctxt->page_size;
> +
> +    libxl_ctxt->alloc_currp = e;
> +
> +    return (void *)s;
> +}
> +
> +static void acpi_mem_free(struct acpi_ctxt *ctxt,
> +                          void *v, uint32_t size)
> +{
> +}
> +
> +static uint8_t acpi_lapic_id(unsigned cpu)
> +{
> +    return cpu * 2;

Is this in accordance with hardware spec?

> +}
> +
> +static int init_acpi_config(libxl__gc *gc, 
> +                            struct xc_dom_image *dom,
> +                            const libxl_domain_build_info *b_info,
> +                            struct acpi_config *config)
> +{

Use goto style error handling in this function please.

> +    xc_interface *xch = dom->xch;
> +    uint32_t domid = dom->guest_domid;
> +    xc_dominfo_t info;
> +    struct hvm_info_table *hvminfo;
> +    int i, rc;
> +
> +    config->dsdt_anycpu = config->dsdt_15cpu = dsdt_pvh;
> +    config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_pvh_len;
> +
> +    rc = xc_domain_getinfo(xch, domid, 1, &info);
> +    if (rc < 0) {
> +        LOG(ERROR, "%s: getdomaininfo failed (rc=%d)", __FUNCTION__, rc);

No need to have __FUNCTION__ -- LOG already prints that.

> +        return rc;
> +    }
> +
> +    hvminfo = libxl__zalloc(gc, sizeof(*hvminfo));
> +
> +    hvminfo->apic_mode = libxl_defbool_val(b_info->u.hvm.apic);
> +
> +    if (dom->nr_vnodes) {
> +        unsigned int *vcpu_to_vnode, *vdistance;
> +        struct xen_vmemrange *vmemrange;
> +        struct acpi_numa *numa = &config->numa;
> +
> +        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
> +                                &numa->nr_vmemranges,
> +                                &hvminfo->nr_vcpus, NULL, NULL, NULL);
> +        if (rc) {
> +            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
> +                __FUNCTION__, rc);
> +            return rc;
> +        }
> +
> +        vmemrange = libxl__zalloc(gc, dom->nr_vmemranges * sizeof(*vmemrange));
> +        vdistance = libxl__zalloc(gc, dom->nr_vnodes * sizeof(*vdistance));
> +        vcpu_to_vnode = libxl__zalloc(gc, hvminfo->nr_vcpus *
> +                                      sizeof(*vcpu_to_vnode));
> +        rc = xc_domain_getvnuma(xch, domid, &numa->nr_vnodes,
> +                                &numa->nr_vmemranges, &hvminfo->nr_vcpus,
> +                                vmemrange, vdistance, vcpu_to_vnode);
> +	if (rc) {
> +            LOG(ERROR, "%s: xc_domain_getvnuma failed (rc=%d)",
> +                __FUNCTION__, rc);
> +            return rc;
> +        }
> +        numa->vmemrange = vmemrange;
> +        numa->vdistance = vdistance;
> +        numa->vcpu_to_vnode = vcpu_to_vnode;
> +    }
> +    else
> +        hvminfo->nr_vcpus = info.max_vcpu_id + 1;

"else" should be right after "}" and please add braces.

> +
> +    for (i = 0; i < hvminfo->nr_vcpus; i++)
> +        hvminfo->vcpu_online[i / 8] |= 1 << (i & 7);
> +
> +    config->hvminfo = hvminfo;
> +
> +    config->lapic_base_address = LAPIC_BASE_ADDRESS;
> +    config->lapic_id = acpi_lapic_id;
> +
> +    return 0;
> +}
> +
> +int libxl__dom_load_acpi(libxl__gc *gc,
> +                         const libxl_domain_build_info *b_info,
> +                         struct xc_dom_image *dom)
> +{
> +    struct acpi_config config = {0};
> +    struct libxl_acpi_ctxt libxl_ctxt;
> +    int rc, acpi_pages_num;
> +    void *acpi_pages;
> +    unsigned long page_mask;
> +
> +    if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) ||
> +        (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE))
> +        return 0;

Please don't use mixed-style error handling.

> +
> +    libxl_ctxt.page_size = XC_DOM_PAGE_SIZE(dom);
> +    libxl_ctxt.page_shift =  XC_DOM_PAGE_SHIFT(dom);
> +    page_mask = (1UL << libxl_ctxt.page_shift) - 1;
> +
> +    libxl_ctxt.c.mem_ops.alloc = mem_alloc;
> +    libxl_ctxt.c.mem_ops.v2p = virt_to_phys;
> +    libxl_ctxt.c.mem_ops.free = acpi_mem_free;
> +
> +    rc = init_acpi_config(gc, dom, b_info, &config);
> +    if (rc) {
> +        LOG(ERROR, "%s: init_acpi_config failed (rc=%d)", __FUNCTION__, rc);
> +        return rc;
> +    }
> +
> +    config.rsdp = (unsigned long)libxl__malloc(gc, libxl_ctxt.page_size);
> +    config.infop = (unsigned long)libxl__malloc(gc, libxl_ctxt.page_size);
> +    /* Pages to hold ACPI tables */
> +    acpi_pages =  libxl__malloc(gc, (NUM_ACPI_PAGES + 1) *
> +                                libxl_ctxt.page_size);
> +
> +    /*
> +     * Set up allocator memory.
> +     * Start next to acpi_info page to avoid fracturing e820.
> +     */
> +    libxl_ctxt.alloc_base_paddr = ACPI_INFO_PHYSICAL_ADDRESS +
> +        libxl_ctxt.page_size;
> +    libxl_ctxt.alloc_base_vaddr = libxl_ctxt.alloc_currp =
> +        (unsigned long)acpi_pages;
> +    libxl_ctxt.alloc_end = (unsigned long)acpi_pages +
> +        (NUM_ACPI_PAGES * libxl_ctxt.page_size);
> +
> +    /* Build the tables. */
> +    rc = acpi_build_tables(&libxl_ctxt.c, &config);
> +    if (rc) {
> +        LOG(ERROR, "%s: acpi_build_tables failed with %d",
> +            __FUNCTION__, rc);
> +        goto out;
> +    }
> +
> +    /* Calculate how many pages are needed for the tables. */
> +    acpi_pages_num =
> +        ((libxl_ctxt.alloc_currp - (unsigned long)acpi_pages)
> +         >> libxl_ctxt.page_shift) +
> +        ((libxl_ctxt.alloc_currp & page_mask) ? 1 : 0);
> +
> +    dom->acpi_modules[0].data = (void *)config.rsdp;
> +    dom->acpi_modules[0].length = 64;
> +    dom->acpi_modules[0].guest_addr_out = RSDP_ADDRESS;
> +
> +    dom->acpi_modules[1].data = (void *)config.infop;
> +    dom->acpi_modules[1].length = 4096;
> +    dom->acpi_modules[1].guest_addr_out = ACPI_INFO_PHYSICAL_ADDRESS;
> +
> +    dom->acpi_modules[2].data = acpi_pages;
> +    dom->acpi_modules[2].length = acpi_pages_num  << libxl_ctxt.page_shift;
> +    dom->acpi_modules[2].guest_addr_out = ACPI_INFO_PHYSICAL_ADDRESS +
> +        libxl_ctxt.page_size;
> +
> +out:
> +
> +    return rc;
> +

Extraneous line.

> +}
> +/*
> + * Local variables:
> + * mode: C
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/tools/libxl/libxl_x86_acpi.h b/tools/libxl/libxl_x86_acpi.h
> new file mode 100644
> index 0000000..3622dd0
> --- /dev/null
> +++ b/tools/libxl/libxl_x86_acpi.h
> @@ -0,0 +1,35 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU Lesser General Public License as published
> + * by the Free Software Foundation; version 2.1 only. with the special
> + * exception on linking described in file LICENSE.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
> + */
> +
> +#ifndef LIBXL_X86_ACPI_H
> +#define LIBXL_X86_ACPI_H
> +
> +#include "libxl_internal.h"
> +
> +#define ASSERT(x) assert(x)
> +
> +static inline int test_bit(unsigned int b, const void *p)
> +{
> +    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
> +}
> +
> +#endif /* LIBXL_X_86_ACPI_H */
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> -- 
> 1.8.3.1
> 

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

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

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

On Mon, Sep 19, 2016 at 08:19:39PM -0400, Boris Ostrovsky wrote:
> Load ACPI modules into guest space
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

Code-wise:

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

There are still some inconsistencies in coding style.

> ---
> Changes in v4:
> * Style updates
> 
>  tools/libxc/xc_dom_core.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)
> 
> diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
> index ebada89..be3ccd7 100644
> --- a/tools/libxc/xc_dom_core.c
> +++ b/tools/libxc/xc_dom_core.c
> @@ -1040,6 +1040,97 @@ 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)

Here.

> +        {
> +            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)

Here.

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

Here.

> +            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 +1188,10 @@ int xc_dom_build_image(struct xc_dom_image *dom)
>          memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size);
>      }
>  
> +    /* load ACPI tables */
> +    if ( xc_dom_load_acpi(dom) != 0 )
> +        goto err;
> +
>      /* allocate other pages */
>      if ( !dom->arch_hooks->p2m_base_supported ||
>           dom->parms.p2m_base >= dom->parms.virt_base ||
> -- 
> 1.8.3.1
> 

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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-22 10:53   ` Wei Liu
@ 2016-09-22 15:57     ` Boris Ostrovsky
  2016-09-22 15:57       ` Wei Liu
  0 siblings, 1 reply; 59+ messages in thread
From: Boris Ostrovsky @ 2016-09-22 15:57 UTC (permalink / raw)
  To: Wei Liu
  Cc: andrew.cooper3, ian.jackson, xen-devel, julien.grall, jbeulich,
	zhaoshenglong, roger.pau

On 09/22/2016 06:53 AM, Wei Liu wrote:
>
>> diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
>> index 90427ff..336358c 100644
>> --- a/tools/libxl/Makefile
>> +++ b/tools/libxl/Makefile
>> @@ -75,7 +75,21 @@ else
>>  LIBXL_OBJS-y += libxl_no_colo.o
>>  endif
>>  
>> -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
>> +ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
>> +ACPI_FILES = dsdt_pvh.c
>> +ACPI_OBJS  = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
>> +$(ACPI_FILES): acpi
>> +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
>> +vpath build.c $(ACPI_PATH)/
>> +vpath static_tables.c $(ACPI_PATH)/
>> +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
>> +
>> +.PHONY: acpi
>> +acpi:
>> +	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
>> +-include acpi
> Useless include?

Hmm... I thought there was a reason I put this here but I can't remember
now.

>
>> +
>> +static uint8_t acpi_lapic_id(unsigned cpu)
>> +{
>> +    return cpu * 2;
> Is this in accordance with hardware spec?

That's how we (Xen) encode APIC IDs for guests.  For example, see
vlapic_reset().

>> +
>> +int libxl__dom_load_acpi(libxl__gc *gc,
>> +                         const libxl_domain_build_info *b_info,
>> +                         struct xc_dom_image *dom)
>> +{
>> +    struct acpi_config config = {0};
>> +    struct libxl_acpi_ctxt libxl_ctxt;
>> +    int rc, acpi_pages_num;
>> +    void *acpi_pages;
>> +    unsigned long page_mask;
>> +
>> +    if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) ||
>> +        (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE))
>> +        return 0;
> Please don't use mixed-style error handling.

Not sure I understand what you are asking for. You want 'return rc'? Or
'goto out'?

-boris


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

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

* Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
  2016-09-22 15:57     ` Boris Ostrovsky
@ 2016-09-22 15:57       ` Wei Liu
  0 siblings, 0 replies; 59+ messages in thread
From: Wei Liu @ 2016-09-22 15:57 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Wei Liu, andrew.cooper3, ian.jackson, xen-devel, julien.grall,
	jbeulich, zhaoshenglong, roger.pau

On Thu, Sep 22, 2016 at 11:57:18AM -0400, Boris Ostrovsky wrote:
> On 09/22/2016 06:53 AM, Wei Liu wrote:
> >
> >> diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
> >> index 90427ff..336358c 100644
> >> --- a/tools/libxl/Makefile
> >> +++ b/tools/libxl/Makefile
> >> @@ -75,7 +75,21 @@ else
> >>  LIBXL_OBJS-y += libxl_no_colo.o
> >>  endif
> >>  
> >> -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
> >> +ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
> >> +ACPI_FILES = dsdt_pvh.c
> >> +ACPI_OBJS  = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
> >> +$(ACPI_FILES): acpi
> >> +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
> >> +vpath build.c $(ACPI_PATH)/
> >> +vpath static_tables.c $(ACPI_PATH)/
> >> +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
> >> +
> >> +.PHONY: acpi
> >> +acpi:
> >> +	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
> >> +-include acpi
> > Useless include?
> 
> Hmm... I thought there was a reason I put this here but I can't remember
> now.
> 
> >
> >> +
> >> +static uint8_t acpi_lapic_id(unsigned cpu)
> >> +{
> >> +    return cpu * 2;
> > Is this in accordance with hardware spec?
> 
> That's how we (Xen) encode APIC IDs for guests.  For example, see
> vlapic_reset().
> 

OK.

> >> +
> >> +int libxl__dom_load_acpi(libxl__gc *gc,
> >> +                         const libxl_domain_build_info *b_info,
> >> +                         struct xc_dom_image *dom)
> >> +{
> >> +    struct acpi_config config = {0};
> >> +    struct libxl_acpi_ctxt libxl_ctxt;
> >> +    int rc, acpi_pages_num;
> >> +    void *acpi_pages;
> >> +    unsigned long page_mask;
> >> +
> >> +    if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) ||
> >> +        (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE))
> >> +        return 0;
> > Please don't use mixed-style error handling.
> 
> Not sure I understand what you are asking for. You want 'return rc'? Or
> 'goto out'?
> 

goto out please.

> -boris
> 

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

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

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

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

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