Make ACPI builder available to components other than hvmloader
v5 cover Make ACPI builder available to components other than hvmloader
The goal here is to build ACPI tables for PVHv2/HVMlite guests while reusing existing hvmloader's ACPI builder code. The builder is provided as a library in tools/libacpi.
This is verion 5 of the series, see individual patches for changes. It can be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v5
Major changes:
* Generate GPL-licensed portion of DSDT (patch 3)
Boris Ostrovsky (21):
acpi: Makefile should better tolerate interrupts
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
libxc/libxl: Allow multiple ACPI modules
libxl/acpi: Add ACPI e820 entry
libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
libxl: 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 | 18 +-
MAINTAINERS | 1 +
tools/firmware/hvmloader/Makefile | 24 +-
tools/firmware/hvmloader/acpi/Makefile | 72 ----
tools/firmware/hvmloader/acpi/ssdt_tpm.asl | 30 --
tools/firmware/hvmloader/config.h | 2 +
tools/firmware/hvmloader/hvmloader.c | 2 +-
tools/firmware/hvmloader/ovmf.c | 2 +-
tools/firmware/hvmloader/rombios.c | 2 +-
tools/firmware/hvmloader/seabios.c | 5 +-
tools/firmware/hvmloader/util.c | 52 ++-
tools/firmware/hvmloader/util.h | 4 +-
tools/firmware/rombios/32bit/Makefile | 2 +-
tools/firmware/rombios/32bit/tcgbios/Makefile | 2 +-
tools/firmware/rombios/32bit/util.h | 2 +-
tools/libacpi/COPYING | 480 +++++++++++++++++++++
tools/libacpi/Makefile | 96 +++++
tools/{firmware/hvmloader/acpi => libacpi}/README | 16 +-
.../{firmware/hvmloader/acpi => libacpi}/acpi2_0.h | 19 +-
tools/{firmware/hvmloader/acpi => libacpi}/build.c | 303 +++++++------
.../{firmware/hvmloader/acpi => libacpi}/dsdt.asl | 51 +--
tools/libacpi/dsdt_acpi_info.asl | 26 ++
tools/libacpi/gpl/COPYING | 22 +
tools/libacpi/gpl/mk_dsdt_gpl.sh | 110 +++++
.../{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 | 19 +-
tools/libxl/libxl_arch.h | 9 +
tools/libxl/libxl_create.c | 22 +-
tools/libxl/libxl_dom.c | 53 ++-
tools/libxl/libxl_x86.c | 43 +-
tools/libxl/libxl_x86_acpi.c | 240 +++++++++++
tools/libxl/libxl_x86_acpi.h | 35 ++
xen/arch/x86/domain.c | 26 +-
42 files changed, 1623 insertions(+), 474 deletions(-)
delete mode 100644 tools/firmware/hvmloader/acpi/Makefile
delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_tpm.asl
create mode 100644 tools/libacpi/COPYING
create mode 100644 tools/libacpi/Makefile
rename tools/{firmware/hvmloader/acpi => libacpi}/README (60%)
rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (95%)
rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (63%)
rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl (91%)
create mode 100644 tools/libacpi/dsdt_acpi_info.asl
create mode 100644 tools/libacpi/gpl/COPYING
create mode 100755 tools/libacpi/gpl/mk_dsdt_gpl.sh
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.hSignature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 1/21 acpi: Makefile should better tolerate interrupts
Intermediate stages of building a target should be made with temporary files that are copied to final target in the end.
---
Changes in v5:
* Now is first patch in the series
* Renamed TMP_SUFFIX to "tmp" (from "tmp__")
tools/firmware/hvmloader/acpi/Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
tools/firmware/hvmloader/acpi/Makefile +13 -7
@@ -22,6 +22,9 @@ OBJS = $(patsubst %.c,%.o,$(C_SRC)) CFLAGS += $(CFLAGS_xeninclude) +# Suffix for temporary files. +TMP_SUFFIX = tmp + vpath iasl $(PATH) all: acpi.a
@@ -34,18 +37,21 @@ mk_dsdt: mk_dsdt.c $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt - awk 'NR > 1 {print s} {s=$$0}' $< > $@ - ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@ + awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(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' dsdt_%cpu.asl: dsdt.asl mk_dsdt - awk 'NR > 1 {print s} {s=$$0}' $< > $@ - ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@ + awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl iasl -vs -p $* -tc $*.asl - sed -e 's/AmlCode/$*/g' $*.hex >$@ - echo "int $*_len=sizeof($*);" >>$@ + sed -e 's/AmlCode/$*/g' $*.hex >$@.$(TMP_SUFFIX) + echo "int $*_len=sizeof($*);" >>$@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ rm -f $*.aml $*.hex iasl:
@@ -63,7 +69,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_*.asl *.$(TMP_SUFFIX) distclean: clean
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v5 01/21] acpi: Makefile should better tolerate interrupts
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 22.09.16 at 21:13, <[email protected]> wrote:
Intermediate stages of building a target should be made with temporary files that are copied to final target in the end.
Signed-off-by Boris Ostrovsky <[email protected]>---
Changes in v5:
* Now is first patch in the series
* RenamedTMP_SUFFIXto "tmp" (from "tmp__")
I'm not really opposed to using the variable, but I think Ian didn't like it, and I think things might read easier a little easier without. The patch can have my ack either way, but I'd like to have Ian's opinion before putting it in.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 01/21] acpi: Makefile should better tolerate interrupts
Jan Beulich writes ("Re: [PATCH v5 01/21] acpi: Makefile should better tolerate interrupts"):
Quoted 10 lines · On 22.09.16 at 21:13, <[email protected]> wrote:
Quoted 8 lines
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 <[email protected]>---
Changes in v5:
* Now is first patch in the series
* RenamedTMP_SUFFIXto "tmp" (from "tmp__")
Quoted 4 lines
I'm not really opposed to using the variable, but I think Ian didn't like it, and I think things might read easier a little easier without. The patch can have my ack either way, but I'd like to have Ian's opinion before putting it in.
I think this is a bikeshed issue. My question was not intended to block the patch. As far as my opinion is relevant, it can go in regardless.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 2/21 acpi: Extract acpi info description into a separate ASL file
In reply to Boris OstrovskyThis code will be needed by PVH guests who don't want to use full DSDT.
--- .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
.gitignore +1 -1
@@ -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
tools/firmware/hvmloader/acpi/Makefile +5 -3
@@ -36,14 +36,16 @@ 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}' $< > $@.$(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' -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}' $< > $@.$(TMP_SUFFIX) + cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX) mv -f $@.$(TMP_SUFFIX) $@
@@ -69,7 +71,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 *.$(TMP_SUFFIX) + rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*cpu*.asl *.$(TMP_SUFFIX) distclean: clean
tools/firmware/hvmloader/acpi/dsdt.asl +0 -19
@@ -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
tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl new file +26 -0
@@ -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 + } + }
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v5 02/21] acpi: Extract acpi info description into a separate ASL file
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 22.09.16 at 21:13, <[email protected]> wrote:
This code will be needed by PVH guests who don't want to use full DSDT.
Signed-off-by Boris Ostrovsky <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 3/21 acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Boris OstrovskySome 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 chunk of code in dsdt.asl that implements _PIC method
(2) A chunk of ASL generator in mk_dsdt.c that describes with PCI interrupt routing.
This code will now be generated by a GPL-only script which will be invoked only when ACPI builder's Makefile is called with GPL variable set.
We also strip license header from generated ASL files to prevent inadverent use of those files with incorrect license.
---
Changes in v5:
* Generate GPL-only ASL with mk_dsdt_gpl.sh script
* Strip license header from generated DSDT ASL
tools/firmware/hvmloader/Makefile | 4 + tools/firmware/hvmloader/acpi/Makefile | 14 ++- tools/firmware/hvmloader/acpi/dsdt.asl | 14 --- tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh | 110 +++++++++++++++++++++++ tools/firmware/hvmloader/acpi/mk_dsdt.c | 68 +------------- 5 files changed, 126 insertions(+), 84 deletions(-) create mode 100755 tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh
tools/firmware/hvmloader/Makefile +4 -0
@@ -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
tools/firmware/hvmloader/acpi/Makefile +11 -3
@@ -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)
@@ -36,18 +37,25 @@ 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: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + # Strip license comment + sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + ./gpl/mk_dsdt_gpl.sh >> $@.$(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' -dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt +dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + ./gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX) cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX) mv -f $@.$(TMP_SUFFIX) $@ +endif $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl iasl -vs -p $* -tc $*.asl
tools/firmware/hvmloader/acpi/dsdt.asl +0 -14
@@ -26,20 +26,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0) 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) {
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +110 -0
110 lines not on this page · raw message
tools/firmware/hvmloader/acpi/mk_dsdt.c +1 -67
80 lines not on this page · raw message
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
tools/firmware/hvmloader/Makefile ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest · line 70
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 22.09.16 at 21:13, <[email protected]> wrote:
tools/firmware/hvmloader/Makefile +3
-0@@ -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
This could (and hence imo should) be a single line.
Also I think I did say so before - please use := for simple assignments like this one.
tools/firmware/hvmloader/acpi/Makefile line 21
Quoted 9 lines
tools/firmware/hvmloader/acpi/Makefile +2
-1@@ -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)
I don't think the use of tabs here is really helpful. In no case should a blank be followed by a tab.
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 45
Quoted 11 lines
tools/firmware/hvmloader/acpi/Makefile +5
-1@@ -36,18 +37,25 @@ 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: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + # Strip license comment + sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + ./gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
I don't think the leading ./ is necessary here, ...
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 47
Quoted 2 lines
tools/firmware/hvmloader/acpi/Makefile +0
-0cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)
... other than e.g. here.
Also I think shell scripts get better invoked via $(SHELL), to avoid running into problems when on some file system they end up without execute permission.
Quoted 20 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +17
-0@@ -0,0 +1,110 @@ +# 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/>. +# + +printf "\n /* Beginning of GPL-only code */\n\n" + +printf " /* _S3 and _S4 are in separate SSDTs */\n" +printf " Name (\_S5, Package (0x04) {\n"
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 27
Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+printf " 0x00, /* PM1a_CNT.SLP_TYP */\n" +printf " 0x00, /* PM1b_CNT.SLP_TYP */\n" +printf " 0x00, /* reserved */\n" +printf " 0x00 /* reserved */\n" +printf " })\n" + +printf " Name(PICD, 0)\n" +printf " Method(_PIC, 1) {\n" +printf " Store(Arg0, PICD)\n" +printf " }\n"
Wouldn't this be better readable with "echo", avoiding all the \n instances? Actually this seems to even apply to most if not everything further down, as so far I didn't spot a case where you actually pass anything other than just a format string.
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 39
Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+# PCI-ISA link definitions + +# BUFA: List of ISA IRQs available for linking to PCI INTx. +printf " Scope ( \_SB.PCI0 ) {\n" +printf " Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )\n" +# BUFB: IRQ descriptor for returning from link-device _CRS methods. +printf " Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )\n" +printf " CreateWordField ( BUFB, 0x01, IRQV )\n" + +links=(A B C D)
Is this portable?
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 39
Quoted 2 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +2
-0+for i in `seq 0 3`; +do
I think you want to use only one of ; and newline as separator here. And is there a reason to prefer backquotes over the imo better legible $()?
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 51
Quoted 9 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +9
-0+ link=${links[$i]} + printf " Device ( LNK$link ) {\n" + printf " Name ( _HID, EISAID(\"PNP0C0F\") )\n" #PCI interrupt link + printf " Name ( _UID, $((i+1)))\n" + printf " Method ( _STA, 0) {\n" + printf " If ( And(PIR$link, 0x80) ) {\n" + printf " Return ( 0x09 )\n" + printf " }\n" + printf " Else {\n"
Since you re-write all of this anyway, please put the Else-es on the same lines as the closing braces.
Quoted 29 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +29
-0+ printf " Return ( 0x0B )\n" + printf " }\n" + printf " }\n" + printf " Method ( _PRS ) {\n" + printf " Return ( BUFA )\n" + printf " }\n" + printf " Method ( _DIS ) {\n" + printf " Or ( PIR$link, 0x80, PIR$link )\n" + printf " }\n" + printf " Method ( _CRS ) {\n" + printf " And ( PIR$link, 0x0f, Local0 )\n" + printf " ShiftLeft ( 0x1, Local0, IRQV )\n" + printf " Return ( BUFB )\n" + printf " }\n" + printf " Method ( _SRS, 1 ) {\n" + printf " CreateWordField ( ARG0, 0x01, IRQ1 )\n" + printf " FindSetRightBit ( IRQ1, Local0 )\n" + printf " Decrement ( Local0 )\n" + printf " Store ( Local0, PIR$link )\n" + printf " }\n" + printf " }\n" +done + +# PCI interrupt routing definitions +# _PRT: Method to return routing table. +printf " Method ( _PRT, 0 ) {\n" +printf " If ( PICD ) {\n" +printf " Return ( PRTA )\n" +printf " }\n"
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 90
Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+printf " Return ( PRTP )\n" +printf " }\n" + +# PRTP: PIC routing table (via ISA links). +printf " Name(PRTP, Package() {\n" +for dev in `seq 1 31`; +do + for intx in `seq 0 3`; # INTA-D + do + link_idx=$(((dev+intx)&3))
Just like in C, please have blanks around binary operators.
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 91
Quoted 1 line
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +1
-0+ printf " Package(){0x%04xffff, %u, \\_SB.PCI0.LNK%c, 0},\n" $dev $intx ${links[$link_idx]}
I think you should really use \\\\ here, to avoid some shell having an extension giving meaning to \_. And please split this long line.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Jan Beulich writes ("Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 3 lines
Also I think shell scripts get better invoked via $(SHELL), to avoid running into problems when on some file system they end up without execute permission.
My understanding is that the reason for this convention in our build system is the concern that /bin/sh might be something horribly ancient and buggy.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Jan BeulichQuoted 14 lines · Jan Beulich
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 45
Quoted 12 lines
tools/firmware/hvmloader/acpi/Makefile +5
-1@@ -36,18 +37,25 @@ 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: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + # Strip license comment + sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + ./gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)I don't think the leading ./ is necessary here, ...
Quoted 3 lines
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 47
Quoted 2 lines
tools/firmware/hvmloader/acpi/Makefile +0
-0cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)... other than e.g. here.
What is the difference between the two?
Quoted 31 lines
Also I think shell scripts get better invoked via $(SHELL), to avoid running into problems when on some file system they end up without execute permission.
Quoted 26 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +23
-0@@ -0,0 +1,110 @@ +# 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/>. +# + +printf "\n /* Beginning of GPL-only code */\n\n" + +printf " /* _S3 and _S4 are in separate SSDTs */\n" +printf " Name (\_S5, Package (0x04) {\n" +printf " 0x00, /* PM1a_CNT.SLP_TYP */\n" +printf " 0x00, /* PM1b_CNT.SLP_TYP */\n" +printf " 0x00, /* reserved */\n" +printf " 0x00 /* reserved */\n" +printf " })\n" +
Quoted 8 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 27
Quoted 4 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +4
-0+printf " Name(PICD, 0)\n" +printf " Method(_PIC, 1) {\n" +printf " Store(Arg0, PICD)\n" +printf " }\n"Wouldn't this be better readable with "echo", avoiding all the \n instances? Actually this seems to even apply to most if not everything further down, as so far I didn't spot a case where you actually pass anything other than just a format string.
Format string is the only reason. There are a couple of instances where output is formatted and I felt that having both echo and printf would feel inconsistent.
Quoted 12 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 39
Quoted 11 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+# PCI-ISA link definitions + +# BUFA: List of ISA IRQs available for linking to PCI INTx. +printf " Scope ( \_SB.PCI0 ) {\n" +printf " Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )\n" +# BUFB: IRQ descriptor for returning from link-device _CRS methods. +printf " Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )\n" +printf " CreateWordField ( BUFB, 0x01, IRQV )\n" + +links=(A B C D)Is this portable?
I heard that associative arrays sometimes have portability issues but this is a regular one. FWIW this runs on a 2009 Fedora12.
Would 'declare -a links' help?
Quoted 6 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 39
Quoted 3 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +2
-0+for i in `seq 0 3`; +doI think you want to use only one of ; and newline as separator here. And is there a reason to prefer backquotes over the imo better legible $()?
No reason, that's the style I usually use. I can change to $() if that's the preferred one.
(I will resend this patch only to avoid spamming everyone with 20 already-acked patches)
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Boris Ostrovsky writes ("Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+printf "\n /* Beginning of GPL-only code */\n\n" + +printf " /* _S3 and _S4 are in separate SSDTs */\n" +printf " Name (\_S5, Package (0x04) {\n" +printf " 0x00, /* PM1a_CNT.SLP_TYP */\n" +printf " 0x00, /* PM1b_CNT.SLP_TYP */\n" +printf " 0x00, /* reserved */\n" +printf " 0x00 /* reserved */\n" +printf " })\n" +Quoted 8 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 27
Quoted 4 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +4
-0+printf " Name(PICD, 0)\n" +printf " Method(_PIC, 1) {\n" +printf " Store(Arg0, PICD)\n" +printf " }\n"Wouldn't this be better readable with "echo", avoiding all the \n instances? Actually this seems to even apply to most if not everything further down, as so far I didn't spot a case where you actually pass anything other than just a format string.
Quoted 3 lines
Format string is the only reason. There are a couple of instances where output is formatted and I felt that having both echo and printf would feel inconsistent.
I don't think there is anything wrong with inconsistency.
But really, why not make this (or most of it) a here document (ie with <<) ? That would remove a lot of the quoting clutter (and would also avoid any bugs where shell metacharacters or printf metacharacters are unintentionally written unquoted).
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Quoted 19 lines · Ian Jackson
Boris Ostrovsky writes ("Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +4
-0+printf "\n /* Beginning of GPL-only code */\n\n" + +printf " /* _S3 and _S4 are in separate SSDTs */\n" +printf " Name (\_S5, Package (0x04) {\n"tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 27
Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+printf " 0x00, /* PM1a_CNT.SLP_TYP */\n" +printf " 0x00, /* PM1b_CNT.SLP_TYP */\n" +printf " 0x00, /* reserved */\n" +printf " 0x00 /* reserved */\n" +printf " })\n" + +printf " Name(PICD, 0)\n" +printf " Method(_PIC, 1) {\n" +printf " Store(Arg0, PICD)\n" +printf " }\n"Wouldn't this be better readable with "echo", avoiding all the \n instances? Actually this seems to even apply to most if not everything further down, as so far I didn't spot a case where you actually pass anything other than just a format string.
Quoted 7 lines
Quoted 3 lines
Format string is the only reason. There are a couple of instances where output is formatted and I felt that having both echo and printf would feel inconsistent.
I don't think there is anything wrong with inconsistency.
But really, why not make this (or most of it) a here document (ie with <<) ?
Sorry, I don't follow this. What is a "here document"?
-boris
Quoted 5 lines
That would remove a lot of the quoting clutter (and would also avoid any bugs where shell metacharacters or printf metacharacters are unintentionally written unquoted).
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Boris Ostrovsky writes ("Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 5 lines · Ian Jackson
Quoted 2 lines
But really, why not make this (or most of it) a here document (ie with <<) ?
Sorry, I don't follow this. What is a "here document"?
It's a redirection from a literal, introduced with <<.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
You probably want the version that looks like this <<'END' as it doesn't do interpolation on the literal text, rather than the version without the single quotes (which _does_ do interpolation of $ and `.)
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Quoted 6 lines · Ian Jackson
Boris Ostrovsky writes ("Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 4 lines · Ian Jackson
Quoted 2 lines
But really, why not make this (or most of it) a here document (ie with <<) ?
Sorry, I don't follow this. What is a "here document"?
It's a redirection from a literal, introduced with <<.
Ah. I've never heard "here document" term.
-boris
Quoted 9 lines
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
You probably want the version that looks like this <<'END' as it doesn't do interpolation on the literal text, rather than the version without the single quotes (which _does_ do interpolation of $ and `.)
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Boris OstrovskyQuoted 16 lines
Quoted 1 line
Quoted 1 line · On 23.09.16 at 16:23, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 45
Quoted 12 lines
tools/firmware/hvmloader/acpi/Makefile +5
-1@@ -36,18 +37,25 @@ 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: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + # Strip license comment + sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX) + ./gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)I don't think the leading ./ is necessary here, ...
Quoted 5 lines
Quoted 3 lines
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 47
Quoted 2 lines
tools/firmware/hvmloader/acpi/Makefile +0
-0cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)... other than e.g. here.
What is the difference between the two?
The latter would then lack any directory components, and hence would become subject to lookup through $PATH, which would fail if . is not included in it (and which would possibly do the wrong thing even if it was).
Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +23
-0@@ -0,0 +1,110 @@ +# 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/>. +# + +printf "\n /* Beginning of GPL-only code */\n\n" + +printf " /* _S3 and _S4 are in separate SSDTs */\n" +printf " Name (\_S5, Package (0x04) {\n" +printf " 0x00, /* PM1a_CNT.SLP_TYP */\n" +printf " 0x00, /* PM1b_CNT.SLP_TYP */\n" +printf " 0x00, /* reserved */\n" +printf " 0x00 /* reserved */\n" +printf " })\n" +Quoted 8 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 27
Quoted 4 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +4
-0+printf " Name(PICD, 0)\n" +printf " Method(_PIC, 1) {\n" +printf " Store(Arg0, PICD)\n" +printf " }\n"Wouldn't this be better readable with "echo", avoiding all the \n instances? Actually this seems to even apply to most if not everything further down, as so far I didn't spot a case where you actually pass anything other than just a format string.
Quoted 3 lines
Format string is the only reason. There are a couple of instances where output is formatted and I felt that having both echo and printf would feel inconsistent.
Hmm, I think avoiding the many \n would warrant this slight inconsistency.
Quoted 12 lines
Quoted 11 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 39
Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10
-0+# PCI-ISA link definitions + +# BUFA: List of ISA IRQs available for linking to PCI INTx. +printf " Scope ( \_SB.PCI0 ) {\n" +printf " Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )\n" +# BUFB: IRQ descriptor for returning from link-device _CRS methods. +printf " Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )\n" +printf " CreateWordField ( BUFB, 0x01, IRQV )\n" + +links=(A B C D)Is this portable?
Quoted 4 lines
I heard that associative arrays sometimes have portability issues but this is a regular one. FWIW this runs on a 2009 Fedora12.
Would 'declare -a links' help?
I don't know - honestly I'm not a shell script expert. All I can say is that I wasn't able to find the construct above e.g. in SUS v6.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Boris OstrovskyBoris Ostrovsky writes ("[PATCH v5 03/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 11 lines
Some code (specifically, introduced by commit
801d469ad("[HVM] ACPI support patch 3 of 4: ACPI_PRTtable.")) 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 chunk of code in dsdt.asl that implements_PICmethod
(2) A chunk of ASL generator inmk_dsdt.cthat describes with PCI interrupt routing.
Quoted 8 lines
This code will now be generated by a GPL-only script which will be invoked only when ACPI builder's
Makefileis called with GPL variable set.We also strip license header from generated ASL files to prevent inadverent use of those files with incorrect license.
Signed-off-by Boris Ostrovsky <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 4/21 acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
In reply to Boris OstrovskyACPI 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
gpl/mk_dsdt_asl.sh file will remain GPL-only pending permission to relicense from Lenovo due to commit 801d469ad ("[HVM] ACPI support patch 3 of 4: ACPI _PRT table."))
---
CC: Daniel Kiper <[email protected]>
CC: Stefan Berger <[email protected]>
CC: Kouya Shimura <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Keir Fraser <[email protected]>
CC: Simon Horman <[email protected]>
CC: Lars Kurth <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
---
Changes in v5:
* dsdt.asl is also relicensed
tools/firmware/hvmloader/acpi/COPYING | 480 ++++++++++++++++++++++++++ tools/firmware/hvmloader/acpi/Makefile | 18 +- tools/firmware/hvmloader/acpi/acpi2_0.h | 19 +- tools/firmware/hvmloader/acpi/build.c | 18 +- tools/firmware/hvmloader/acpi/dsdt.asl | 18 +- tools/firmware/hvmloader/acpi/gpl/COPYING | 22 ++ 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 +- 12 files changed, 574 insertions(+), 82 deletions(-) create mode 100644 tools/firmware/hvmloader/acpi/COPYING create mode 100644 tools/firmware/hvmloader/acpi/gpl/COPYING
tools/firmware/hvmloader/acpi/COPYING new file +480 -0
@@ -0,0 +1,480 @@ +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. + +Where clause 3 is invoked in order to relicense under the GPL then +this shall be considered to be GPL v2 only for files which have +specified LGPL v2.1 only. + +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. + + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS
tools/firmware/hvmloader/acpi/Makefile +8 -10
@@ -1,17 +1,15 @@ # # Copyright (c) 2004, Intel Corporation. # -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2, as published by the Free Software Foundation. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; version 2.1 only. with the special +# exception on linking described in file LICENSE. # -# This program is distributed in the hope it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; If not, see <http://www.gnu.org/licenses/>. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# NU Lesser General Public License for more details. # XEN_ROOT = $(CURDIR)/../../../..
tools/firmware/hvmloader/acpi/acpi2_0.h +8 -11
@@ -1,18 +1,15 @@/* * Copyright (c) 2004, Intel Corporation. * -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; If not, see <http://www.gnu.org/licenses/>. +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. * +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. */ #ifndef _ACPI_2_0_H_#define _ACPI_2_0_H_
tools/firmware/hvmloader/acpi/build.c +8 -10
@@ -2,17 +2,15 @@* Copyright (c) 2004, Intel Corporation. * Copyright (c) 2006, Keir Fraser, XenSource Inc. * -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, version -* 2, as published by the Free Software Foundation. +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. * -* This program is distributed in the hope it will be useful, but WITHOUT ANY -* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -* details. -* -* You should have received a copy of the GNU General Public License along with -* this program; If not, see <http://www.gnu.org/licenses/>. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. */ #include "acpi2_0.h"
tools/firmware/hvmloader/acpi/dsdt.asl +8 -10
@@ -3,17 +3,15 @@ * * Copyright (c) 2004, Intel Corporation. * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; If not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. */ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
tools/firmware/hvmloader/acpi/gpl/COPYING new file +22 -0
@@ -0,0 +1,22 @@ +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/> + + +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.
tools/firmware/hvmloader/acpi/mk_dsdt.c +12 -0
@@ -1,3 +1,15 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ +#include <stdio.h> #include <stdarg.h> #include <stdint.h>
tools/firmware/hvmloader/acpi/ssdt_pm.asl +4 -7
@@ -5,17 +5,14 @@ * Copyright (c) 2008 Citrix Systems, Inc. * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; If not, see <http://www.gnu.org/licenses/>. + * GNU Lesser General Public License for more details. */ /*
tools/firmware/hvmloader/acpi/ssdt_s3.asl +4 -7
@@ -4,17 +4,14 @@ * Copyright (c) 2011 Citrix Systems, Inc. * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; If not, see <http://www.gnu.org/licenses/>. + * GNU Lesser General Public License for more details. */ DefinitionBlock ("SSDT_S3.aml", "SSDT", 2, "Xen", "HVM", 0)
tools/firmware/hvmloader/acpi/ssdt_s4.asl +4 -7
@@ -4,17 +4,14 @@ * Copyright (c) 2011 Citrix Systems, Inc. * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; If not, see <http://www.gnu.org/licenses/>. + * GNU Lesser General Public License for more details. */ DefinitionBlock ("SSDT_S4.aml", "SSDT", 2, "Xen", "HVM", 0)
tools/firmware/hvmloader/acpi/ssdt_tpm.asl +8 -10
@@ -3,17 +3,15 @@ * * Copyright (c) 2006, IBM Corporation. * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; If not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. */ /* SSDT for TPM TIS Interface for Xen with Qemu device model. */
tools/firmware/hvmloader/acpi/static_tables.c +8 -10
@@ -2,17 +2,15 @@* Copyright (c) 2004, Intel Corporation. * Copyright (c) 2006, Keir Fraser, XenSource Inc. * -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. * -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; If not, see <http://www.gnu.org/licenses/>. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. */ #include "acpi2_0.h"
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v5 04/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
Boris Ostrovsky writes ("[PATCH v5 04/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1"):
Quoted 1 line
ACPI builder is currently distributed under GPLv2 license.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 04/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
In reply to Boris OstrovskyQuoted 9 lines · Ken Lancaster
My apologies for the delay, this is approved.
We approve the action to re-license http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=801d469ad8b2b88f669326327df03d03200efbfb under LGPLv2.1 as requested.
Best,
Ken Lancaster
..snip..
Heya!
Sending this email to xen-devel mailing list.
Ken,
Thank you so much for helping out with this!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v5 04/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
ACK
-----Original Message-----
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Monday, November 14, 2016 3:05 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Ken Lancaster
Subject: Re: [PATCH v5 04/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
Quoted 9 lines · Ken Lancaster
My apologies for the delay, this is approved.
We approve the action to re-license http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=801d469ad8b2b88f669326327df03d03200efbfb under LGPLv2.1 as requested.
Best,
Ken Lancaster
..snip..
Heya!
Sending this email to xen-devel mailing list.
Ken,
Thank you so much for helping out with this!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 5/21 acpi/hvmloader: Collect processor and NUMA info in hvmloader
In reply to Boris OstrovskyNo need for ACPI code to rely on hvm_info variable.
---
Changes in v5:
* Constified pointer in test_bit()
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 | 4 +-- 4 files changed, 50 insertions(+), 26 deletions(-)
tools/firmware/hvmloader/acpi/build.c +28 -24
@@ -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;
tools/firmware/hvmloader/acpi/libacpi.h +11 -0
@@ -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, ....)
tools/firmware/hvmloader/util.c +9 -0
@@ -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 ;
tools/firmware/hvmloader/util.h +2 -2
@@ -48,9 +48,9 @@ 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 ))); +return !!(((const uint8_t *)p)[b>>3 ] & (1u <<(b&7 ))); }static inline int test_and_clear_bit (int nr,volatile void *addr)
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 6/21 acpi/hvmloader: Set TIS header address in hvmloader
In reply to Boris OstrovskyUsers other than hvmloader may provide TIS address as virtual.
--- tools/firmware/hvmloader/acpi/build.c | 9 ++++----- tools/firmware/hvmloader/acpi/libacpi.h | 3 +++ tools/firmware/hvmloader/config.h | 2 ++ tools/firmware/hvmloader/util.c | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-)
tools/firmware/hvmloader/acpi/build.c +4 -5
@@ -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 ;
tools/firmware/hvmloader/acpi/libacpi.h +3 -0
@@ -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, ....)
tools/firmware/hvmloader/config.h +2 -0
@@ -56,6 +56,8 @@ extern uint8_t ioapic_version;/* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */ #define PCI_MEM_END 0xfc000000 +#define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL +extern unsigned long pci_mem_start, pci_mem_end;extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
tools/firmware/hvmloader/util.c +4 -0
@@ -919,6 +919,10 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,if ( !strncmp (xenstore_read ("platform/acpi_s4" ,"1" ),"1" ,1 ) ) config->table_flags |=ACPI_HAS_SSDT_S4 ; + config->table_flags |=ACPI_HAS_TCPA ; + + config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS ; + config->numa.nr_vmemranges = nr_vmemranges; config->numa.nr_vnodes = nr_vnodes; config->numa.vcpu_to_vnode = vcpu_to_vnode;
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 7/21 acpi/hvmloader: Make providing IOAPIC in MADT optional
In reply to Boris Ostrovsky--- tools/firmware/hvmloader/acpi/build.c | 70 ++++++++++++++++++--------------- tools/firmware/hvmloader/acpi/libacpi.h | 1 + tools/firmware/hvmloader/util.c | 2 +- 3 files changed, 40 insertions(+), 33 deletions(-)
tools/firmware/hvmloader/acpi/build.c +38 -32
@@ -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++ )
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
@@ -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 {
tools/firmware/hvmloader/util.c +1 -1
@@ -919,7 +919,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,if ( !strncmp (xenstore_read ("platform/acpi_s4" ,"1" ),"1" ,1 ) ) config->table_flags |=ACPI_HAS_SSDT_S4 ; - config->table_flags |=ACPI_HAS_TCPA ; + config->table_flags |= (ACPI_HAS_TCPA |ACPI_HAS_IOAPIC ); config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS ;
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 8/21 acpi/hvmloader: Build WAET optionally
In reply to Boris Ostrovsky--- tools/firmware/hvmloader/acpi/build.c | 10 +++++++--- tools/firmware/hvmloader/acpi/libacpi.h | 1 + tools/firmware/hvmloader/util.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-)
tools/firmware/hvmloader/acpi/build.c +7 -3
@@ -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 ) {
tools/firmware/hvmloader/acpi/libacpi.h +1 -0
@@ -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 {
tools/firmware/hvmloader/util.c +1 -1
@@ -919,7 +919,7 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,if ( !strncmp (xenstore_read ("platform/acpi_s4" ,"1" ),"1" ,1 ) ) config->table_flags |=ACPI_HAS_SSDT_S4 ; - config->table_flags |= (ACPI_HAS_TCPA |ACPI_HAS_IOAPIC ); + config->table_flags |= (ACPI_HAS_TCPA |ACPI_HAS_IOAPIC |ACPI_HAS_WAET ); config->tis_hdr = (uint16_t *)ACPI_TIS_HDR_ADDRESS ;
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 9/21 acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops
In reply to Boris OstrovskyComponents 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.
--- 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(-)
tools/firmware/hvmloader/acpi/build.c +52 -43
@@ -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 ;
tools/firmware/hvmloader/acpi/libacpi.h +9 -1
@@ -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__ */
tools/firmware/hvmloader/util.c +23 -1
@@ -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); }
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 10/21 acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables
In reply to Boris OstrovskyNon-hvmloader users may be building tables in virtual address space and therefore we need to make sure that values that end up in tables are physical addresses.
--- tools/firmware/hvmloader/acpi/build.c | 47 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 23 deletions(-)
tools/firmware/hvmloader/acpi/build.c +24 -23
@@ -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 ));
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 11/21 acpi/hvmloader: Link ACPI object files directly
In reply to Boris OstrovskyACPI sources will be available to various component which will build them according to their own rules. ACPI's Makefile will only generate necessary source files.
---
Changes in v5:
* .gitignore lists all dsdt* / ssdt* files as not tracked.
* Clarified use of TMP_SUFFIX afor iasl bug workaround
.gitignore | 7 +++-- tools/firmware/hvmloader/Makefile | 11 +++++++- tools/firmware/hvmloader/acpi/Makefile | 47 +++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 26 deletions(-)
.gitignore +3 -4
@@ -127,13 +127,12 @@ 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* tools/firmware/hvmloader/hvmloader +tools/firmware/hvmloader/mk_dsdt tools/firmware/hvmloader/roms.h tools/firmware/hvmloader/roms.inc +tools/firmware/hvmloader/ssdt* tools/firmware/rombios/BIOS-bochs-[^/]* tools/firmware/rombios/_rombios[^/]*_.c tools/firmware/rombios/rombios[^/]*.s
tools/firmware/hvmloader/Makefile +10 -1
@@ -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
tools/firmware/hvmloader/acpi/Makefile +26 -21
86 lines not on this page · raw message
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 12/21 acpi/hvmloader: Include file/paths adjustments
In reply to Boris OstrovskyIn prepearation to moving acpi sources into generally available libacpi:
1. Pass IOAPIC/LAPIC/PCI mask values via struct acpi_config
2. Modify include files search paths to point to acpi directory
3. Macro-ise include file for build.c that defines various utilities used by that file. Users of libacpi will be expected to define this macro when compiling build.c
---
Changes in v5:
* Include <xen/hvm/hvm_info_table.h> in build.c
tools/firmware/hvmloader/Makefile | 3 ++- tools/firmware/hvmloader/acpi/README | 16 ++++++++++++---- tools/firmware/hvmloader/acpi/build.c | 20 +++++++++++--------- 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, 53 insertions(+), 23 deletions(-)
tools/firmware/hvmloader/Makefile +2 -1
@@ -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)
tools/firmware/hvmloader/acpi/README +12 -4
@@ -1,11 +1,19 @@ -ACPI Table for domain firmware +ACPI builder for domain firmware -INSTALL +BUILDING ACPI ----------------- -Simply make is OK. -# make +Users of ACPI builder are expected to provide an include file that makes available +the following: +* strncpy +* printf +* NULL +* test_bit +* offsetof +When compiling build.c, the name of this include file should be given to +compiler as -DLIBACPI_STDUTILS=\"<filename>\". See tools/firmware/hvmloader/Makefile +for an example. Note on DSDT Table ------------------
tools/firmware/hvmloader/acpi/build.c +11 -9
@@ -13,15 +13,14 @@* 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_info_table.h> #include <xen/hvm/hvm_xs_strings.h> #include <xen/hvm/params.h> #include <xen/memory.h>
@@ -82,6 +81,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 +100,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 +119,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 +138,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 +155,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 +243,7 @@ static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt, processor->type =ACPI_PROCESSOR_AFFINITY ; processor->length =sizeof (*processor); processor->domain = config->numa.vcpu_to_vnode[i]; - processor->apic_id =LAPIC_ID (i); + processor->apic_id = config->lapic_id (i); processor->flags =ACPI_LOCAL_APIC_AFFIN_ENABLED ; processor++; }
tools/firmware/hvmloader/acpi/libacpi.h +7 -0
@@ -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);
tools/firmware/hvmloader/hvmloader.c +1 -1
@@ -24,8 +24,8 @@#include "config.h" #include "pci_regs.h" #include "apic_regs.h" -#include "acpi/acpi2_0.h" #include "vnuma.h" +#include <acpi2_0.h> #include <xen/version.h> #include <xen/hvm/params.h> #include <xen/arch-x86/hvm/start_info.h>
tools/firmware/hvmloader/rombios.c +1 -1
@@ -24,12 +24,12 @@#include "../rombios/config.h" #include "smbios_types.h" -#include "acpi/libacpi.h" #include "pci_regs.h" #include "util.h" #include "hypercall.h" #include "option_rom.h" +#include <libacpi.h> #include <xen/hvm/params.h> #define ROM_INCLUDE_ROMBIOS
tools/firmware/hvmloader/seabios.c +3 -2
@@ -25,8 +25,9 @@#include "util.h" #include "smbios_types.h" -#include "acpi/acpi2_0.h" -#include "acpi/libacpi.h" + +#include <acpi2_0.h> +#include <libacpi.h> extern unsigned char dsdt_anycpu_qemu_xen[];extern int dsdt_anycpu_qemu_xen_len;
tools/firmware/hvmloader/util.c +13 -2
@@ -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 ) )
tools/firmware/rombios/32bit/Makefile +1 -1
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = 32bitbios_flat.h -CFLAGS += $(CFLAGS_xeninclude) -I.. +CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi SUBDIRS = tcgbios
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = tcgbiosext.o -CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. +CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi .PHONY: all all: $(TARGET)
tools/firmware/rombios/32bit/util.h +1 -1
@@ -1,7 +1,7 @@#ifndef UTIL_H #define UTIL_H -#include "../hvmloader/acpi/acpi2_0.h" +#include <acpi2_0.h> void outb (uint16_t addr,uint8_t val);void outw (uint16_t addr,uint16_t val);
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 13/21 acpi: Move ACPI code to tools/libacpi
In reply to Boris Ostrovsky---
MAINTAINERS | 1 +
tools/firmware/hvmloader/Makefile | 14 ++++++++------
tools/firmware/hvmloader/ovmf.c | 2 +-
tools/firmware/rombios/32bit/Makefile | 2 +-
tools/firmware/rombios/32bit/tcgbios/Makefile | 2 +-
tools/{firmware/hvmloader/acpi => libacpi}/COPYING | 0
tools/{firmware/hvmloader/acpi => libacpi}/Makefile | 2 +-
tools/{firmware/hvmloader/acpi => libacpi}/README | 0
tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h | 0
tools/{firmware/hvmloader/acpi => libacpi}/build.c | 0
tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl | 0
.../hvmloader/acpi => libacpi}/dsdt_acpi_info.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/gpl/COPYING | 0
.../hvmloader/acpi => libacpi}/gpl/mk_dsdt_gpl.sh | 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
21 files changed, 13 insertions(+), 10 deletions(-)
rename tools/{firmware/hvmloader/acpi => libacpi}/COPYING (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/Makefile (98%)
rename tools/{firmware/hvmloader/acpi => libacpi}/README (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt_acpi_info.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/gpl/COPYING (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/gpl/mk_dsdt_gpl.sh (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (100%)MAINTAINERS +1 -0
@@ -138,6 +138,7 @@ S: Supported F: xen/arch/x86/acpi/ F: xen/drivers/acpi/ F: xen/include/acpi/ +F: tools/libacpi/ AMD IOMMU M: Suravee Suthikulpanit <[email protected]>
tools/firmware/hvmloader/Makefile +8 -6
@@ -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
tools/firmware/hvmloader/ovmf.c +1 -1
@@ -23,7 +23,7 @@#include "config.h" #include "smbios_types.h" -#include "acpi/libacpi.h" +#include "libacpi.h" #include "apic_regs.h" #include "../rombios/config.h" #include "util.h"
tools/firmware/rombios/32bit/Makefile +1 -1
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = 32bitbios_flat.h -CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi +CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi SUBDIRS = tcgbios
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = tcgbiosext.o -CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi +CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../../libacpi .PHONY: all all: $(TARGET)
tools/libacpi/COPYING renamed from tools/firmware/hvmloader/acpi/COPYING +0 -0
tools/libacpi/Makefile renamed from tools/firmware/hvmloader/acpi/Makefile +1 -1
@@ -12,7 +12,7 @@ # NU Lesser General Public License for more details. # -XEN_ROOT = $(CURDIR)/../../../.. +XEN_ROOT = $(CURDIR)/../.. include $(XEN_ROOT)/tools/firmware/Rules.mk MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt
tools/libacpi/README renamed from tools/firmware/hvmloader/acpi/README +0 -0
tools/libacpi/acpi2_0.h renamed from tools/firmware/hvmloader/acpi/acpi2_0.h +0 -0
tools/libacpi/build.c renamed from tools/firmware/hvmloader/acpi/build.c +0 -0
tools/libacpi/dsdt.asl renamed from tools/firmware/hvmloader/acpi/dsdt.asl +0 -0
tools/libacpi/dsdt_acpi_info.asl renamed from tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl +0 -0
tools/libacpi/gpl/COPYING renamed from tools/firmware/hvmloader/acpi/gpl/COPYING +0 -0
tools/libacpi/gpl/mk_dsdt_gpl.sh renamed from tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh +0 -0
tools/libacpi/libacpi.h renamed from tools/firmware/hvmloader/acpi/libacpi.h +0 -0
tools/libacpi/mk_dsdt.c renamed from tools/firmware/hvmloader/acpi/mk_dsdt.c +0 -0
tools/libacpi/ssdt_pm.asl renamed from tools/firmware/hvmloader/acpi/ssdt_pm.asl +0 -0
tools/libacpi/ssdt_s3.asl renamed from tools/firmware/hvmloader/acpi/ssdt_s3.asl +0 -0
tools/libacpi/ssdt_s4.asl renamed from tools/firmware/hvmloader/acpi/ssdt_s4.asl +0 -0
tools/libacpi/ssdt_tpm.asl renamed from tools/firmware/hvmloader/acpi/ssdt_tpm.asl +0 -0
tools/libacpi/static_tables.c renamed from tools/firmware/hvmloader/acpi/static_tables.c +0 -0
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 14/21 x86: Allow LAPIC-only emulation_flags for HVM guests
In reply to Boris OstrovskyPVHv2 guests may request LAPIC emulation (and nothing else)
--- xen/arch/x86/domain.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
xen/arch/x86/domain.c +16 -10
@@ -545,25 +545,31 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, }else { -if ( (config->emulation_flags & ~XEN_X86_EMU_ALL ) !=0 ) +uint32_t emflags; + +if (is_hardware_domain (d) ) + config->emulation_flags |=XEN_X86_EMU_PIT ; + + emflags = config->emulation_flags; +if ( emflags & ~XEN_X86_EMU_ALL ) {printk (XENLOG_G_ERR "d%d: Invalid emulation bitmap: %#x\n" , - d->domain_id, config->emulation_flags); + d->domain_id, emflags);return -EINVAL ; } -if (is_hardware_domain (d) ) - config->emulation_flags |=XEN_X86_EMU_PIT ; -if ( config->emulation_flags !=0 && - (config->emulation_flags != - (is_hvm_domain (d) ?XEN_X86_EMU_ALL :XEN_X86_EMU_PIT )) ) + +/* PVHv2 guests can request emulated APIC. */ +if ( emflags && + (is_hvm_domain (d) ? ((emflags !=XEN_X86_EMU_ALL ) && + (emflags !=XEN_X86_EMU_LAPIC )) : + (emflags !=XEN_X86_EMU_PIT )) ) {printk (XENLOG_G_ERR "d%d: Xen does not allow %s domain creation " "with the current selection of emulators: %#x\n" , - d->domain_id,is_hvm_domain (d) ?"HVM" :"PV" , - config->emulation_flags); + d->domain_id,is_hvm_domain (d) ?"HVM" :"PV" , emflags);return -EOPNOTSUPP ; } - d->arch.emulation_flags = config->emulation_flags; + d->arch.emulation_flags = emflags; }if (has_hvm_container_domain (d) )
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 15/21 libacpi: Build DSDT for PVH guests
In reply to Boris OstrovskyPVH 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.
--- tools/libacpi/Makefile | 7 ++++++- tools/libacpi/mk_dsdt.c | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
tools/libacpi/Makefile +6 -1
@@ -18,7 +18,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt C_SRC-$(GPL) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c -C_SRC = $(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) # Suffix for temporary files.
@@ -60,6 +60,11 @@ $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh 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 >> $@ + $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex > $@.$(TMP_SUFFIX)
tools/libacpi/mk_dsdt.c +8 -0
@@ -23,6 +23,7 @@ static unsigned int indent_level;static bool debug = false;typedef enum dm_version { +QEMU_NONE ,QEMU_XEN_TRADITIONAL ,QEMU_XEN , }dm_version ;
@@ -135,6 +136,8 @@ int main(int argc, char **argv) dm_version =QEMU_XEN ; }else if (strcmp (optarg,"qemu-xen-traditional" ) ==0 ) { dm_version =QEMU_XEN_TRADITIONAL ; + }else if (strcmp (optarg,"none" ) ==0 ) { + dm_version =QEMU_NONE ; }else {fprintf (stderr,"Unknown device model version `%s'.\n" , optarg);return -1 ;
@@ -252,6 +255,11 @@ int main(int argc, char **argv)pop_block (); +if (dm_version ==QEMU_NONE ) { +pop_block (); +return 0 ; + } +/* Define GPE control method. */ push_block ("Scope" ,"\\_GPE" ); push_block("Method",
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 16/21 libxc/libxl: Allow multiple ACPI modules
In reply to Boris OstrovskyProvide 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.
--- tools/libxc/include/xc_dom.h | 5 +++-- tools/libxc/xc_dom_hvmloader.c | 3 ++- tools/libxl/libxl_dom.c | 26 ++++++++++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-)
tools/libxc/include/xc_dom.h +3 -2
@@ -212,8 +212,9 @@ struct xc_dom_image {/* BIOS/Firmware passed to HVMLOADER */ struct xc_hvm_firmware_module system_firmware_module; -/* Extra ACPI tables passed to HVMLOADER */ -struct xc_hvm_firmware_module acpi_module; +/* Extra ACPI tables */ +#define MAX_ACPI_MODULES 4 +struct xc_hvm_firmware_module acpi_modules[MAX_ACPI_MODULES ];/* Extra SMBIOS structures passed to HVMLOADER */ struct xc_hvm_firmware_module smbios_module;
tools/libxc/xc_dom_hvmloader.c +2 -1
@@ -172,7 +172,8 @@ static int modules_init(struct xc_dom_image *dom) rc =module_init_one (dom, &dom->system_firmware_module,"System Firmware module" );if ( rc ) goto err; - rc =module_init_one (dom, &dom->acpi_module,"ACPI module" ); +/* Only one module can be added */ + rc =module_init_one (dom, &dom->acpi_modules[0 ],"ACPI module" );if ( rc ) goto err; rc =module_init_one (dom, &dom->smbios_module,"SMBIOS module" );if ( rc ) goto err;
tools/libxl/libxl_dom.c +18 -8
@@ -818,7 +818,8 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid,static int hvm_build_set_xs_values (libxl__gc *gc,uint32_t domid, -struct xc_dom_image *dom) +struct xc_dom_image *dom, +const libxl_domain_build_info *info) {char *path =NULL ;int ret =0 ;
@@ -839,18 +840,20 @@ static int hvm_build_set_xs_values(libxl__gc *gc, goto err; } -if (dom->acpi_module.guest_addr_out) { +/* Only one module can be passed. PVHv2 guests do not support this. */ +if (dom->acpi_modules[0 ].guest_addr_out && + info->device_model_version !=LIBXL_DEVICE_MODEL_VERSION_NONE ) { path =GCSPRINTF ("/local/domain/%d/" HVM_XS_ACPI_PT_ADDRESS , domid); ret =libxl__xs_printf (gc,XBT_NULL , path,"0x%" PRIx64, - dom->acpi_module.guest_addr_out); + dom->acpi_modules[0 ].guest_addr_out);if (ret) goto err; path =GCSPRINTF ("/local/domain/%d/" HVM_XS_ACPI_PT_LENGTH , domid); ret =libxl__xs_printf (gc,XBT_NULL , path,"0x%x" , - dom->acpi_module.length); + dom->acpi_modules[0 ].length);if (ret) goto err; }
@@ -994,6 +997,13 @@ static int libxl__domain_firmware(libxl__gc *gc, }if (info->u.hvm.acpi_firmware) { + +if (info->device_model_version ==LIBXL_DEVICE_MODEL_VERSION_NONE ) { +LOGE (ERROR ,"PVH guests do not allow loading ACPI modules" ); + rc =ERROR_FAIL ; + goto out; + } + data =NULL ; e =libxl_read_file_contents (ctx, info->u.hvm.acpi_firmware, &data, &datalen);
@@ -1005,9 +1015,9 @@ static int libxl__domain_firmware(libxl__gc *gc, }libxl__ptr_add (gc, data);if (datalen) { -/* Only accept non-empty files */ - dom->acpi_module.data = data; - dom->acpi_module.length = (uint32_t )datalen; +/* Only accept a non-empty file */ + dom->acpi_modules[0 ].data = data; + dom->acpi_modules[0 ].length = (uint32_t )datalen; } }
@@ -1143,7 +1153,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, goto out; } - rc =hvm_build_set_xs_values (gc, domid, dom); + rc =hvm_build_set_xs_values (gc, domid, dom, info);if (rc !=0 ) {LOG (ERROR ,"hvm build set xenstore values failed" ); goto out;
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 17/21 libxl/acpi: Add ACPI e820 entry
In reply to Boris OstrovskyAdd entry for ACPI tables created for PVHv2 guests to e820 map.
--- tools/libxl/libxl_dom.c | 8 ++++---- tools/libxl/libxl_x86.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-)
tools/libxl/libxl_dom.c +4 -4
@@ -1134,16 +1134,16 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, dom->vnode_to_pnode[i] = info->vnuma_nodes[i].pnode; } + rc =libxl__build_dom (gc, domid, info, state, dom); +if (rc !=0 ) + goto out; + rc =libxl__arch_domain_construct_memmap (gc, d_config, domid, dom);if (rc !=0 ) {LOG (ERROR ,"setting domain memory map failed" ); goto out; } - rc =libxl__build_dom (gc, domid, info, state, dom); -if (rc !=0 ) - goto out; - rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port, &state->store_mfn, state->console_port, &state->console_mfn, state->store_domid,
tools/libxl/libxl_x86.c +15 -0
@@ -492,6 +492,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,uint64_t highmem_size = dom->highmem_end ? dom->highmem_end - (1ull <<32 ) :0 ;uint32_t lowmem_start = dom->device_model ?GUEST_LOW_MEM_START_DEFAULT :0 ; +unsigned page_size =XC_DOM_PAGE_SIZE (dom);/* Add all rdm entries. */ for (i =0 ; i < d_config->num_rdms; i++)
@@ -503,6 +504,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,if (highmem_size) e820_entries++; +for (i =0 ; i <MAX_ACPI_MODULES ; i++) +if (dom->acpi_modules[i].length) + e820_entries++; +if (e820_entries >=E820MAX ) {LOG (ERROR ,"Ooops! Too many entries in the memory map!" ); rc =ERROR_INVAL ;
@@ -528,6 +533,16 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc, nr++; } +for (i =0 ; i <MAX_ACPI_MODULES ; i++) { +if (dom->acpi_modules[i].length) { + e820[nr].addr = dom->acpi_modules[i].guest_addr_out & ~(page_size -1 ); + e820[nr].size = dom->acpi_modules[i].length + + (dom->acpi_modules[i].guest_addr_out & (page_size -1 )); + e820[nr].type =E820_ACPI ; + nr++; + } + } +/* High memory */ if (highmem_size) { e820[nr].addr = ((uint64_t )1 <<32 );
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 18/21 libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
In reply to Boris Ostrovsky--- tools/libxl/Makefile | 2 ++ tools/libxl/libxl_arch.h | 6 ++++++ tools/libxl/libxl_dom.c | 19 +++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-)
tools/libxl/Makefile +2 -0
@@ -166,6 +166,8 @@ $(XL_OBJS) $(TEST_PROG_OBJS) _libxl.api-for-check: \ $(XL_OBJS): CFLAGS += $(CFLAGS_XL) $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it. +libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools # include libacpi/x86.h + SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
tools/libxl/libxl_arch.h +6 -0
@@ -62,4 +62,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,uint32_t domid, struct xc_dom_image *dom); +#if defined(__i386__) || defined(__x86_64__) + +#define LAPIC_BASE_ADDRESS 0xfee00000 + +#endif +#endif
tools/libxl/libxl_dom.c +15 -4
@@ -1077,10 +1077,21 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, dom->target_pages = mem_size >>XC_PAGE_SHIFT ;if (dom->mmio_size ==0 && device_model) dom->mmio_size =HVM_BELOW_4G_MMIO_LENGTH ; -else if (dom->mmio_size ==0 && !device_model) - dom->mmio_size =GB (4 ) - - ((X86_HVM_END_SPECIAL_REGION -X86_HVM_NR_SPECIAL_PAGES ) - <<XC_PAGE_SHIFT ); +else if (dom->mmio_size ==0 && !device_model) { +#if defined(__i386__) || defined(__x86_64__) +if (libxl_defbool_val (info->u.hvm.apic)) { +/* Make sure LAPIC_BASE_ADDRESS is below special pages */ +assert (((((X86_HVM_END_SPECIAL_REGION -X86_HVM_NR_SPECIAL_PAGES ) + <<XC_PAGE_SHIFT ) -LAPIC_BASE_ADDRESS )) >=XC_PAGE_SIZE ); + dom->mmio_size =GB (4 ) -LAPIC_BASE_ADDRESS ; + }else + dom->mmio_size =GB (4 ) - + ((X86_HVM_END_SPECIAL_REGION -X86_HVM_NR_SPECIAL_PAGES ) + <<XC_PAGE_SHIFT ); +#else +assert (1 ); +#endif + } lowmem_end = mem_size; highmem_end =0 ; mmio_start = (1ull <<32 ) - dom->mmio_size;
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 19/21 libxl: Initialize domain build info before calling libxl__domain_make
In reply to Boris Ostrovskylibxl__domain_make() may want to use b_info so we should set defaults a little earlier.
--- tools/libxl/libxl_create.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
tools/libxl/libxl_create.c +11 -11
@@ -899,17 +899,6 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } - ret =libxl__domain_make (gc, d_config, &domid, &state->config); -if (ret) { -LOG (ERROR ,"cannot make domain: %d" , ret); - dcs->guest_domid = domid; - ret =ERROR_FAIL ; - goto error_out; - } - - dcs->guest_domid = domid; - dcs->sdss.dm.guest_domid =0 ;/* means we haven't spawned */ - ret =libxl__domain_build_info_setdefault (gc, &d_config->b_info);if (ret) {LOG (ERROR ,"Unable to set domain build info defaults" );
@@ -923,6 +912,17 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } + ret =libxl__domain_make (gc, d_config, &domid, &state->config); +if (ret) { +LOG (ERROR ,"cannot make domain: %d" , ret); + dcs->guest_domid = domid; + ret =ERROR_FAIL ; + goto error_out; + } + + dcs->guest_domid = domid; + dcs->sdss.dm.guest_domid =0 ;/* means we haven't spawned */ +/* * Set the dm version quite early so that libxl doesn't have to pass the * build info around just to know if the domain has a device model or not.
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 20/21 libxl/acpi: Build ACPI tables for HVMlite guests
In reply to Boris Ostrovsky---
Changes in v5:
* Dropped include from Makefile
* .gitignore drops all libxl/ssdt* and libxl/ssdt* files from tracking
* Various style adjustments
.gitignore | 11 +- tools/libacpi/build.c | 6 +- tools/libacpi/libacpi.h | 6 +- tools/libxl/Makefile | 17 ++- tools/libxl/libxl_arch.h | 3 + tools/libxl/libxl_x86.c | 28 +++-- tools/libxl/libxl_x86_acpi.c | 240 +++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_x86_acpi.h | 35 +++++++ 8 files changed, 328 insertions(+), 18 deletions(-) create mode 100644 tools/libxl/libxl_x86_acpi.c create mode 100644 tools/libxl/libxl_x86_acpi.h
.gitignore +7 -4
@@ -172,15 +172,18 @@ 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* +tools/libxl/libxlu_cfg_y.output +tools/libxl/mk_dsdt +tools/libxl/ssdt* tools/libxl/testenum tools/libxl/testenum.c tools/libxl/tmp.* -tools/libxl/_libxl.api-for-check -tools/libxl/*.api-ok +tools/libxl/xl tools/misc/cpuperf/cpuperf-perfcntr tools/misc/cpuperf/cpuperf-xen tools/misc/xc_shadow
tools/libacpi/build.c +3 -3
@@ -497,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;
@@ -632,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 ; }/*
tools/libacpi/libacpi.h +3 -3
@@ -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__ */
tools/libxl/Makefile +16 -1
@@ -75,7 +75,20 @@ 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) + +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 +180,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 +323,7 @@ clean: $(RM) -f testidl.c.new testidl.c *.api-ok $(RM) -f xenlight.pc $(RM) -f xlutil.pc + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean distclean: clean $(RM) -f xenlight.pc.in xlutil.pc.in
tools/libxl/libxl_arch.h +3 -0
@@ -66,6 +66,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,#define LAPIC_BASE_ADDRESS 0xfee00000 +int libxl__dom_load_acpi (libxl__gc *gc, +const libxl_domain_build_info *b_info, +struct xc_dom_image *dom);#endif #endif
tools/libxl/libxl_x86.c +21 -7
@@ -8,13 +8,18 @@ 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 ; +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 { -/* PV or HVM domains without a device model. */ xc_config->emulation_flags =0 ; }
@@ -366,7 +371,16 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,libxl_domain_build_info *info, struct xc_dom_image *dom) { -return 0 ; + int rc = 0; + +if ((info->type ==LIBXL_DOMAIN_TYPE_HVM ) && + (info->device_model_version ==LIBXL_DEVICE_MODEL_VERSION_NONE )) { + rc =libxl__dom_load_acpi (gc, info, dom); +if (rc !=0 ) +LOGE (ERROR ,"libxl_dom_load_acpi failed" ); + } + +return rc; }/* Return 0 on success, ERROR_* on failure. */
tools/libxl/libxl_x86_acpi.c new file +240 -0
240 lines not on this page · raw message
tools/libxl/libxl_x86_acpi.h new file +35 -0
@@ -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 !!(((const uint8_t *)p)[b>>3 ] & (1u <<(b&7 ))); +} + +#endif /* LIBXL_X_86_ACPI_H */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v5 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 2 lines · Boris Ostrovsky
Signed-off-by Boris Ostrovsky <[email protected]>Acked-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v5 21/21 libxc/xc_dom_core: Copy ACPI tables to guest space
In reply to Boris OstrovskyLoad ACPI modules into guest space
---
Changes ni v5:
* Style adjustments
tools/libxc/xc_dom_core.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+)
tools/libxc/xc_dom_core.c +95 -0
@@ -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 ||
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel