Make ACPI builder available to components other than hvmloader
v4 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 4 of the series, see individual patches for changes. It can be fetched from git://oss.oracle.com/git/bostrovs/xen.git:acpi_v4
The most "interesting" part here (besides addressing v3 comments) is working around licensing issues. This is mostly patch 2.
Boris Ostrovsky (21):
acpi: Extract acpi info description into a separate ASL file
acpi: Prevent GPL-only code from seeping into non-GPL binaries
acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1 acpi/hvmloader: Collect processor and NUMA info in hvmloader acpi/hvmloader: Set TIS header address in hvmloader acpi/hvmloader: Make providing IOAPIC in MADT optional acpi/hvmloader: Build WAET optionally
acpi/hvmloader: Replace mem_alloc() and virt_to_phys() with memory ops acpi/hvmloader: Translate all addresses when assigning addresses in
ACPI tables
acpi/hvmloader: Link ACPI object files directly acpi/hvmloader: Include file/paths adjustments
acpi: Move ACPI code to tools/libacpi
x86: Allow LAPIC-only emulation_flags for HVM guests
libacpi: Build DSDT for PVH guests
acpi: Makefile should better tolerate interrupts libxc/libxl: Allow multiple ACPI modules
libxl/acpi: Add ACPI e820 entry
libxl/pvhv2: Include APIC page in MMIO hole for PVHv2 guests
ilibxl: Initialize domain build info before calling libxl__domain_make libxl/acpi: Build ACPI tables for HVMlite guests libxc/xc_dom_core: Copy ACPI tables to guest space
.gitignore | 20 +-
MAINTAINERS | 1 +
tools/firmware/hvmloader/Makefile | 24 +-
tools/firmware/hvmloader/acpi/Makefile | 72 --
tools/firmware/hvmloader/acpi/dsdt.asl | 480 ------------
tools/firmware/hvmloader/acpi/ssdt_tpm.asl | 30 -
tools/firmware/hvmloader/config.h | 2 +
tools/firmware/hvmloader/hvmloader.c | 2 +-
tools/firmware/hvmloader/ovmf.c | 2 +-
tools/firmware/hvmloader/rombios.c | 2 +-
tools/firmware/hvmloader/seabios.c | 5 +-
tools/firmware/hvmloader/util.c | 52 +-
tools/firmware/hvmloader/util.h | 2 +-
tools/firmware/rombios/32bit/Makefile | 2 +-
tools/firmware/rombios/32bit/tcgbios/Makefile | 2 +-
tools/firmware/rombios/32bit/util.h | 2 +-
tools/libacpi/Makefile | 84 ++
tools/{firmware/hvmloader/acpi => libacpi}/README | 16 +-
.../{firmware/hvmloader/acpi => libacpi}/acpi2_0.h | 19 +-
tools/{firmware/hvmloader/acpi => libacpi}/build.c | 303 ++++----
tools/libacpi/dsdt_acpi_info.asl | 26 +
tools/libacpi/gpl/COPYING | 5 +
tools/libacpi/gpl/dsdt.asl | 846 +++++++++++++++++++++
.../{firmware/hvmloader/acpi => libacpi}/libacpi.h | 37 +-
.../{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c | 88 +--
.../hvmloader/acpi => libacpi}/ssdt_pm.asl | 11 +-
.../hvmloader/acpi => libacpi}/ssdt_s3.asl | 11 +-
.../hvmloader/acpi => libacpi}/ssdt_s4.asl | 11 +-
tools/libacpi/ssdt_tpm.asl | 28 +
.../hvmloader/acpi => libacpi}/static_tables.c | 18 +-
tools/libxc/include/xc_dom.h | 5 +-
tools/libxc/xc_dom_core.c | 95 +++
tools/libxc/xc_dom_hvmloader.c | 3 +-
tools/libxl/Makefile | 20 +-
tools/libxl/libxl_arch.h | 9 +
tools/libxl/libxl_create.c | 22 +-
tools/libxl/libxl_dom.c | 53 +-
tools/libxl/libxl_x86.c | 45 +-
tools/libxl/libxl_x86_acpi.c | 243 ++++++
tools/libxl/libxl_x86_acpi.h | 35 +
xen/arch/x86/domain.c | 26 +-
41 files changed, 1847 insertions(+), 912 deletions(-)
delete mode 100644 tools/firmware/hvmloader/acpi/Makefile
delete mode 100644 tools/firmware/hvmloader/acpi/dsdt.asl
delete mode 100644 tools/firmware/hvmloader/acpi/ssdt_tpm.asl
create mode 100644 tools/libacpi/Makefile
rename tools/{firmware/hvmloader/acpi => libacpi}/README (60%)
rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (95%)
rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (63%)
create mode 100644 tools/libacpi/dsdt_acpi_info.asl
create mode 100644 tools/libacpi/gpl/COPYING
create mode 100644 tools/libacpi/gpl/dsdt.asl
rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (64%)
rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (82%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (97%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (62%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (62%)
create mode 100644 tools/libacpi/ssdt_tpm.asl
rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (90%)
create mode 100644 tools/libxl/libxl_x86_acpi.c
create mode 100644 tools/libxl/libxl_x86_acpi.hSignature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 1/21 acpi: Extract acpi info description into a separate ASL file
This code will be needed by PVH guests who don't want to use full DSDT.
---
Changes in v4:
* New patch. This used to be done in a later patch but because we now are trying to keep dsdt.asl GPL-only (in the next patch) it's better to do this here and not touch dsdt.asl later.
.gitignore | 2 +- tools/firmware/hvmloader/acpi/Makefile | 8 +++++--- tools/firmware/hvmloader/acpi/dsdt.asl | 19 ----------------- tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl | 26 ++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 tools/firmware/hvmloader/acpi/dsdt_acpi_info.asl
.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
@@ -33,13 +33,15 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl mk_dsdt: mk_dsdt.c $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c -dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt +dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ + cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@ # NB. awk invocation is a portable alternative to 'head -n -1' -dsdt_%cpu.asl: dsdt.asl mk_dsdt +dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ + cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@ $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
@@ -63,7 +65,7 @@ acpi.a: $(OBJS) clean: rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS) - rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl + rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*cpu*.asl distclean: clean
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 v4 01/21] acpi: Extract acpi info description into a separate ASL file
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/Makefile +1
-1@@ -33,13 +33,15 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl mk_dsdt: mk_dsdt.c $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c -dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt +dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 45
Quoted 10 lines
tools/firmware/hvmloader/acpi/Makefile +3
-1awk 'NR > 1 {print s} {s=$$0}' $< > $@ + cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@ # NB. awk invocation is a portable alternative to 'head -n -1' -dsdt_%cpu.asl: dsdt.asl mk_dsdt +dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ + cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@
Comments I made on an earlier version now apply here too: In order to properly deal with make interruptions or failures, this output redirection should be replaced by going through a temporary file. Presumably you still have this somewhere later in the series (as it iirc was in v3), but imo that should then really be moved ahead of the patch here.
Everything else looks fine.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 01/21] acpi: Extract acpi info description into a separate ASL file
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/Makefile +2
-1@@ -33,13 +33,15 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl mk_dsdt: mk_dsdt.c $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c -dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt +dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ + cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@
Quoted 12 lines
tools/firmware/hvmloader/acpi/Makefile ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl · line 45
Quoted 6 lines
tools/firmware/hvmloader/acpi/Makefile +2
-1# NB. awk invocation is a portable alternative to 'head -n -1' -dsdt_%cpu.asl: dsdt.asl mk_dsdt +dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ + cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@Comments I made on an earlier version now apply here too: In order to properly deal with make interruptions or failures, this output redirection should be replaced by going through a temporary file. Presumably you still have this somewhere later in the series (as it iirc was in v3), but imo that should then really be moved ahead of the patch here.
Since it looks like I will need to update this Makefile anyway I can move that patch (#15) to be the first.
-boris
Quoted 5 lines
Everything else looks fine.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 2/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 piece of code in dsdt.asl that implements _PIC method
(2) A fragment of ASL generator in mk_dsdt.c that describes PCI interrupt routing.
The cleanest way to deal with this seems to be taking generatedi ASL chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
---
CC: Lars Kurth <[email protected]>
---
Changes in v4:
* New in v4
Added code in new dsdt.asl is
+ Scope ( \_SB.PCI0 )
+ {
+ Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
...
+ })
+ }
tools/firmware/hvmloader/Makefile | 4 + tools/firmware/hvmloader/acpi/Makefile | 9 +- tools/firmware/hvmloader/acpi/dsdt.asl | 461 ---------------- tools/firmware/hvmloader/acpi/gpl/COPYING | 5 + tools/firmware/hvmloader/acpi/gpl/dsdt.asl | 846 +++++++++++++++++++++++++++++ tools/firmware/hvmloader/acpi/mk_dsdt.c | 68 +-- 6 files changed, 862 insertions(+), 531 deletions(-) delete mode 100644 tools/firmware/hvmloader/acpi/dsdt.asl create mode 100644 tools/firmware/hvmloader/acpi/gpl/COPYING create mode 100644 tools/firmware/hvmloader/acpi/gpl/dsdt.asl
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 +6 -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)
@@ -33,16 +34,18 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl mk_dsdt: mk_dsdt.c $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c -dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt +ifeq ($(GPL),y) +dsdt_anycpu_qemu_xen.asl: gpl/dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@ # NB. awk invocation is a portable alternative to 'head -n -1' -dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt +dsdt_%cpu.asl: gpl/dsdt.asl dsdt_acpi_info.asl mk_dsdt awk 'NR > 1 {print s} {s=$$0}' $< > $@ cat dsdt_acpi_info.asl >> $@ ./mk_dsdt --debug=$(debug) --maxcpu $* >> $@ +endif $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl iasl -vs -p $* -tc $*.asl
tools/firmware/hvmloader/acpi/dsdt.asl deleted +0 -461
461 lines not on this page · raw message
tools/firmware/hvmloader/acpi/gpl/COPYING new file +5 -0
@@ -0,0 +1,5 @@ +Unlike files in the directory above that are licensed under GNU Lesser +General Public License version 2.1, files here are licensed under GNU +General Public License version 2. + +A copy of this license can be obtained at <http://www.gnu.org/licenses/>
tools/firmware/hvmloader/acpi/gpl/dsdt.asl new file +846 -0
846 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 v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Boris Ostrovsky writes ("[PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 6 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.
Quoted 7 lines
There are two pieces that we need to be careful about:
(1) A small piece of code in dsdt.asl that implements_PICmethod
(2) A fragment of ASL generator inmk_dsdt.cthat describes PCI interrupt routing.The cleanest way to deal with this seems to be taking generatedi ASL chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
This approach leaves us with the whole of dsdt.asl declared to be GPLv2. If you are trying to relicence it as LGPLv2.1 this is not a good idea.
Using this approach, if at some later point we get the missing ack from Lenovo, we would have to redo the licence review for the whole of dsdt.asl. We would also have to ask Oracle's permission to relicense bits of the build system etc. !
At the very least we should operate separate inbound/outbound licensing for this one file.
But as I wrote on IRC, I think it would also be best to split out _just the troublesome portions_ into their own files, and include them at build time. That way we have file-by-file source licensing.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Quoted 20 lines · Ian Jackson
Boris Ostrovsky writes ("[PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 6 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.Quoted 7 lines
There are two pieces that we need to be careful about:
(1) A small piece of code in dsdt.asl that implements_PICmethod
(2) A fragment of ASL generator inmk_dsdt.cthat describes PCI interrupt routing.The cleanest way to deal with this seems to be taking generatedi ASL chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
This approach leaves us with the whole of dsdt.asl declared to be GPLv2. If you are trying to relicence it as LGPLv2.1 this is not a good idea.
Quoted 7 lines
Using this approach, if at some later point we get the missing ack from Lenovo, we would have to redo the licence review for the whole of dsdt.asl. We would also have to ask Oracle's permission to relicense bits of the build system etc. !
At the very least we should operate separate inbound/outbound licensing for this one file.
Boris was waiting for the appropriate text from me, which I sent to this thread just before your reply came in. I proposed two parts ./COPYING and ./gpl/COPYING
Quoted 3 lines
But as I wrote on IRC, I think it would also be best to split out
_justthe troublesomeportions_into their own files, and include them at build time. That way we have file-by-file source licensing.
As mentioned on IRC, if that can be done, that would preferable. Aka, we would have a LGPLv2.1 dsdt.asl, which then would include the troublesome portions from ./gpl/ optionally when the library is built for gpl.
Regards
Lars
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Ian JacksonQuoted 23 lines · Ian Jackson
Boris Ostrovsky writes ("[PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 6 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.Quoted 7 lines
There are two pieces that we need to be careful about:
(1) A small piece of code in dsdt.asl that implements_PICmethod
(2) A fragment of ASL generator inmk_dsdt.cthat describes PCI interrupt routing.The cleanest way to deal with this seems to be taking generatedi ASL chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
This approach leaves us with the whole of dsdt.asl declared to be GPLv2. If you are trying to relicence it as LGPLv2.1 this is not a good idea.
Using this approach, if at some later point we get the missing ack from Lenovo, we would have to redo the licence review for the whole of dsdt.asl. We would also have to ask Oracle's permission to relicense bits of the build system etc. !
Quoted 6 lines
At the very least we should operate separate inbound/outbound licensing for this one file.
But as I wrote on IRC, I think it would also be best to split out
_justthe troublesomeportions_into their own files, and include them at build time. That way we have file-by-file source licensing.
I must have misunderstood you then, I thought we were talking only about excising code from mk_dsdt.c.
But yes, I can split dsdt.asl as well. Should we keep _S5 definition as GPL-only?
Lenovo patch was
+/* Poweroff support - ties in with qemu emulation */
+ Name (\_S5, Package (0x04)
+ {
+ 0x07, + 0x07, + 0x00, + 0x00
+ })
and now it looks like
/* _S3 and _S4 are in separate SSDTs */
Name (\_S5, Package (0x04)
{
0x00, /* PM1a_CNT.SLP_TYP */
0x00, /* PM1b_CNT.SLP_TYP */
0x00, /* reserved */
0x00 /* reserved */
})My opinion is that using 0x7 would have been the original contribution as the rest is is simply codifying what ACPI spec says. And since 0x7 is no longer used we can re-license it together with the rest of dsdt.asl.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Boris Ostrovsky writes ("Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 2 lines
But yes, I can split dsdt.asl as well. Should we keep
_S5definition as GPL-only?
I think once we're going down this route there is no benefit in trying to argue for individual bits of code-that-was-once-Lenovo's that there is no copyright interest.
So I would split those lines out as well. That will mean multiple includes.
Does iasl have a suitable conditional include syntax or are you going to use `cat' or something in the Makefile ?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Quoted 7 lines · Ian Jackson
Boris Ostrovsky writes ("Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):
Quoted 2 lines
But yes, I can split dsdt.asl as well. Should we keep
_S5definition as GPL-only?I think once we're going down this route there is no benefit in trying to argue for individual bits of code-that-was-once-Lenovo's that there is no copyright interest.
Quoted 5 lines
So I would split those lines out as well. That will mean multiple includes.
Does iasl have a suitable conditional include syntax or are you going to use `cat' or something in the
Makefile?
iasl has -I<path> option but I don't see a conditional. (And I have very vague understanding of ASL syntax in case there is something that can be done in the language itself).
I ran a quick test with 'cat' and it seems to work OK. Besides, we are already using 'cat' implicitly: we append mk_dsdt output to existing *asl file.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Boris OstrovskyQuoted 13 lines · Boris Ostrovsky
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 piece of code in dsdt.asl that implements_PICmethod
(2) A fragment of ASL generator inmk_dsdt.cthat describes PCI interrupt routing.The cleanest way to deal with this seems to be taking generatedi ASL chunk from (2), adding it to dsdt.asl and keeping dsdt.asl GPL-only.
...
tools/firmware/hvmloader/acpi/gpl/COPYING line 5
Quoted 12 lines
tools/firmware/hvmloader/acpi/gpl/COPYING new file +5
-0@@ -0,0 +1,5 @@ +Unlike files in the directory above that are licensed under GNU Lesser +General Public License version 2.1, files here are licensed under GNU +General Public License version 2. + +A copy of this license can be obtained at <http://www.gnu.org/licenses/>
Add the following:
INBOUND LICENSE
Contributions to this directory are made under the LGPLv2.1 *only* as described
in the COPYING file of the parent directory. As LGPLv2.1 is compatible with the
GPLv2, the resulting file is GPLv2 when seen as a whole.
The intention of this inbound license, is to avoid having to ask subsequent
contributors to this directory for permission to change the license from GPLv2
to LGPLv2.1, once we get permission from the remaining copyright holders of
this directory to change the license to LGPLv2.1.
Note: The only outstanding permission required to re-license this directory to
LGPLv2.1 is from Lenovo.
Regards
Lars
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
In reply to Boris Ostrovskytools/firmware/hvmloader/acpi/dsdt.asl
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/dsdt.asl deleted +0
-0
Please try to represent this as a move, not as a delete+create.
Quoted 49 lines
tools/firmware/hvmloader/acpi/dsdt.asl deleted +47
-0+ Scope ( \_SB.PCI0 ) + { + Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } ) + Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } ) + CreateWordField ( BUFB, 0x01, IRQV ) + Device ( LNKA ) { + Name ( _HID, EISAID("PNP0C0F") ) + Name ( _UID, 1 ) + Method ( _STA, 0 ) { + If ( And(PIRA, 0x80) ) { + Return ( 0x09 ) + } + Else { + Return ( 0x0B ) + } + } + Method ( _PRS ) { + Return ( BUFA ) + } + Method ( _DIS ) { + Or ( PIRA, 0x80, PIRA ) + } + Method ( _CRS ) { + And ( PIRA, 0x0f, Local0 ) + ShiftLeft ( 0x1, Local0, IRQV ) + Return ( BUFB ) + } + Method ( _SRS, 1 ) { + CreateWordField ( ARG0, 0x01, IRQ1 ) + FindSetRightBit ( IRQ1, Local0 ) + Decrement ( Local0 ) + Store ( Local0, PIRA ) + } + } + Device ( LNKB ) { + Name(PRTP, Package() + { + Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0}, + Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0}, + Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0}, + Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0}, + Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0}, + Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0}, + }) + + Name(PRTA, Package() + {
tools/firmware/hvmloader/acpi/dsdt.asl
Quoted 10 lines
tools/firmware/hvmloader/acpi/dsdt.asl deleted +9
-0+ Package(){0x0001ffff, 0, 0, 20}, + Package(){0x0001ffff, 1, 0, 21}, + Package(){0x0001ffff, 2, 0, 22}, + Package(){0x0001ffff, 3, 0, 23}, + Package(){0x0002ffff, 0, 0, 24}, + Package(){0x001fffff, 3, 0, 18}, + }) + } +}
I realize this is the easiest route, but how the various hard coded numbers got generated would be completely lost, making it extremely hard to make any changes here down the road. I wonder whether the Makefile / output redirection approach couldn't be easily extended to create all that data via a shell script fragment, if retaining the C source (moved to a separate file) is indeed not an option.
Nor would I think that would qualify here as someone having produced the replacement code without having looked at the original, as was suggested as a criteria before.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Quoted 4 lines · Jan Beulich
tools/firmware/hvmloader/acpi/dsdt.asl
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/dsdt.asl deleted +0
-0Please try to represent this as a move, not as a delete+create.
This was done by 'git mv' and patches were generated with 'git format-patch -M5 ...' so I am not sure how I can convince git to show it as a rename. Maybe increase the argument to -M to something higher?
Quoted 68 lines
Quoted 50 lines
tools/firmware/hvmloader/acpi/dsdt.asl deleted +47
-0+ Scope ( \_SB.PCI0 ) + { + Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } ) + Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } ) + CreateWordField ( BUFB, 0x01, IRQV ) + Device ( LNKA ) { + Name ( _HID, EISAID("PNP0C0F") ) + Name ( _UID, 1 ) + Method ( _STA, 0 ) { + If ( And(PIRA, 0x80) ) { + Return ( 0x09 ) + } + Else { + Return ( 0x0B ) + } + } + Method ( _PRS ) { + Return ( BUFA ) + } + Method ( _DIS ) { + Or ( PIRA, 0x80, PIRA ) + } + Method ( _CRS ) { + And ( PIRA, 0x0f, Local0 ) + ShiftLeft ( 0x1, Local0, IRQV ) + Return ( BUFB ) + } + Method ( _SRS, 1 ) { + CreateWordField ( ARG0, 0x01, IRQ1 ) + FindSetRightBit ( IRQ1, Local0 ) + Decrement ( Local0 ) + Store ( Local0, PIRA ) + } + } + Device ( LNKB ) { + Name(PRTP, Package() + { + Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0}, + Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0}, + Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0}, + Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0}, + Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0}, + Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0}, + }) + + Name(PRTA, Package() + {tools/firmware/hvmloader/acpi/dsdt.asl
Quoted 10 lines
tools/firmware/hvmloader/acpi/dsdt.asl deleted +9
-0+ Package(){0x0001ffff, 0, 0, 20}, + Package(){0x0001ffff, 1, 0, 21}, + Package(){0x0001ffff, 2, 0, 22}, + Package(){0x0001ffff, 3, 0, 23}, + Package(){0x0002ffff, 0, 0, 24}, + Package(){0x001fffff, 3, 0, 18}, + }) + } +}I realize this is the easiest route, but how the various hard coded numbers got generated would be completely lost, making it extremely hard to make any changes here down the road. I wonder whether the
Makefile/ output redirection approach couldn't be easily extended to create all that data via a shell script fragment, if retaining the C source (moved to a separate file) is indeed not an option.
Quoted 3 lines
Nor would I think that would qualify here as someone having produced the replacement code without having looked at the original, as was suggested as a criteria before.
I can do that (but then I think it would also make sense to have it generate _S5 and _PIC methods as well, even though they are "static").
I think bash script would be better than C since we mostly care about loops that generate values and not language constructs such as stmt() and push_blk().
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 02/21] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 15:34, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
tools/firmware/hvmloader/acpi/dsdt.asl
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/dsdt.asl deleted +0
-0Please try to represent this as a move, not as a delete+create.
This was done by 'git mv' and patches were generated with 'git format-patch -M5 ...' so I am not sure how I can convince git to show it as a rename. Maybe increase the argument to -M to something higher?
Or perhaps with the other adjustment carried out, the delta will become small enough.
Quoted 67 lines
Quoted 67 lines
Quoted 49 lines
tools/firmware/hvmloader/acpi/dsdt.asl deleted +47
-0+ Scope ( \_SB.PCI0 ) + { + Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } ) + Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } ) + CreateWordField ( BUFB, 0x01, IRQV ) + Device ( LNKA ) { + Name ( _HID, EISAID("PNP0C0F") ) + Name ( _UID, 1 ) + Method ( _STA, 0 ) { + If ( And(PIRA, 0x80) ) { + Return ( 0x09 ) + } + Else { + Return ( 0x0B ) + } + } + Method ( _PRS ) { + Return ( BUFA ) + } + Method ( _DIS ) { + Or ( PIRA, 0x80, PIRA ) + } + Method ( _CRS ) { + And ( PIRA, 0x0f, Local0 ) + ShiftLeft ( 0x1, Local0, IRQV ) + Return ( BUFB ) + } + Method ( _SRS, 1 ) { + CreateWordField ( ARG0, 0x01, IRQ1 ) + FindSetRightBit ( IRQ1, Local0 ) + Decrement ( Local0 ) + Store ( Local0, PIRA ) + } + } + Device ( LNKB ) { + Name(PRTP, Package() + { + Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0}, + Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0}, + Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0}, + Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0}, + Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0}, + Package(){0x001fffff, 3, \_SB.PCI0.LNKC, 0}, + }) + + Name(PRTA, Package() + {tools/firmware/hvmloader/acpi/dsdt.asl
Quoted 10 lines
tools/firmware/hvmloader/acpi/dsdt.asl deleted +9
-0+ Package(){0x0001ffff, 0, 0, 20}, + Package(){0x0001ffff, 1, 0, 21}, + Package(){0x0001ffff, 2, 0, 22}, + Package(){0x0001ffff, 3, 0, 23}, + Package(){0x0002ffff, 0, 0, 24}, + Package(){0x001fffff, 3, 0, 18}, + }) + } +}I realize this is the easiest route, but how the various hard coded numbers got generated would be completely lost, making it extremely hard to make any changes here down the road. I wonder whether the
Makefile/ output redirection approach couldn't be easily extended to create all that data via a shell script fragment, if retaining the C source (moved to a separate file) is indeed not an option.
Quoted 6 lines
Quoted 3 lines
Nor would I think that would qualify here as someone having produced the replacement code without having looked at the original, as was suggested as a criteria before.
I can do that (but then I think it would also make sense to have it generate
_S5and_PICmethods as well, even though they are "static").
Sounds reasonable.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 3/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
(dsdt.asl remains GPLv2 as we might need permission from Lenovo due to commit 801d469ad ("[HVM] ACPI support patch 3 of 4: ACPI _PRT table."))
---
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]>
CC: [email protected]
---
Changes in v4:
* Dropped dsdt.asl until Lenovo ACK is received (note that mk_dsdt.c *is* made LGPL)
tools/firmware/hvmloader/acpi/Makefile | 18 ++++++++---------- tools/firmware/hvmloader/acpi/acpi2_0.h | 19 ++++++++----------- tools/firmware/hvmloader/acpi/build.c | 18 ++++++++---------- tools/firmware/hvmloader/acpi/mk_dsdt.c | 12 ++++++++++++ tools/firmware/hvmloader/acpi/ssdt_pm.asl | 11 ++++------- tools/firmware/hvmloader/acpi/ssdt_s3.asl | 11 ++++------- tools/firmware/hvmloader/acpi/ssdt_s4.asl | 11 ++++------- tools/firmware/hvmloader/acpi/ssdt_tpm.asl | 18 ++++++++---------- tools/firmware/hvmloader/acpi/static_tables.c | 18 ++++++++---------- 9 files changed, 64 insertions(+), 72 deletions(-)
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/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 v4 03/21] acpi: Re-license ACPI builder files from GPLv2 to LGPLv2.1
Quoted 41 lines · Boris Ostrovsky
ACPI builder is currently distributed under GPLv2 license.
We plan to make the builder available to components other than the hvmloader (which is also GPLv2). Some of these components (such as libxl) may be distributed under LGPL-2.1 so that they can be used by non-GPLv2 callers. But this will not be possible if we incorporate the ACPI builder in those other components.
To avoid this problem we are relicensing sources in ACPI bulder directory to the Lesser GNU Public License (LGPL) version 2.1
(dsdt.asl remains GPLv2 as we might need permission from Lenovo due to commit
801d469ad("[HVM] ACPI support patch 3 of 4: ACPI_PRTtable."))Signed-off-by Boris Ostrovsky <[email protected]>Acked-by Daniel Kiper <[email protected]>Acked-by Stefan Berger <[email protected]>Acked-by Kouya Shimura <[email protected]>Acked-by Jan Beulich <[email protected]>Acked-by Kevin Tian <[email protected]>Acked-by Keir Fraser <[email protected]>Acked-by Simon Horman <[email protected]>Acked-by Lars Kurth <[email protected]>VirtualIron and Sun contributions]
---
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]>
CC: [email protected]
---
Quoted 5 lines
Changes in v4:
* Dropped dsdt.asl until Lenovo ACK is received (note thatmk_dsdt.c*is* made LGPL)
tools/firmware/hvmloader/acpi/Makefile| 18 ++++++++----------
The directory tools/firmware/hvmloader/acpi/ should contain a COPYING file containing the text following text
[1] http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/COPYING
I would replace the following block in [1] with a more verbose description,
which provides additional context and states our intention.
1 Note that the only valid version of the LGPL as far as the files in
2 this directory (and its subdirectories) are concerned is _this_ 3 particular version of the license (i.e., *only* v2.1, not v2.2 or v3.x 4 or whatever), unless explicitly otherwise stated.
This library is licensed under LGPL v2.1 to allow its usage in LGPL-2.1 libraries such as libxl. Note that the only valid version of the LGPL as far as the files in this directory (and its subdirectories) are concerned is _this_ particular version of the license (i.e., *only* v2.1, not v2.2 or v3.x, unless explicitly otherwise stated.
After this block
6 Where clause 3 is invoked in order to relicense under the GPL then
7 this shall be considered to be GPL v2 only for files which have 8 specified LGPL v2.1 only.
add
gpl sub-directory
=================
This directory contains a gpl sub-directory which contains code licensed under the GPL v2, because we have not yet been able to get the permission to relicense the relevant code to LGPL v2.1. See gpl/COPYING for more information.
The makefile in this component allows to build a GPL and LGPL only variant of this library, the latter omits all GPL source code.
Regards
Lars
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 4/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 v4:
* Constified mode things (struct acpi_config's hvminfo, test_bit's argument)
* Removed xen/memory.h from libacpi.h
tools/firmware/hvmloader/acpi/build.c | 52 ++++++++++++++++++--------------- tools/firmware/hvmloader/acpi/libacpi.h | 11 +++++++ tools/firmware/hvmloader/util.c | 9 ++++++ tools/firmware/hvmloader/util.h | 2 +- 4 files changed, 49 insertions(+), 25 deletions(-)
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 +1 -1
@@ -47,7 +47,7 @@ void __bug(char *file, int line) __attribute__((noreturn));#define max_t (type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) -static inline int test_bit (unsigned int b,void *p) +static inline int test_bit (unsigned int b,const void *p) {return !!(((uint8_t *)p)[b>>3 ] & (1u <<(b&7 ))); }
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 04/21] acpi/hvmloader: Collect processor and NUMA info in hvmloader
tools/firmware/hvmloader/util.h void __bug(char *file, int line) __attribute__((noreturn)); · line 52
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/firmware/hvmloader/util.h +1
-1@@ -47,7 +47,7 @@ void __bug(char *file, int line) __attribute__((noreturn));#define max_t (type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) -static inline int test_bit (unsigned int b,void *p) +static inline int test_bit (unsigned int b,const void *p) {return !!(((uint8_t *)p)[b>>3 ] & (1u <<(b&7 )));
But then please also avoid casting away constness here. With that corrected,
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 5/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 v4 6/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 v4 7/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 v4 8/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.
---
Changes in v4:
* Added comment to acpi_mem_free()
tools/firmware/hvmloader/acpi/build.c | 95 ++++++++++++++++++--------------- tools/firmware/hvmloader/acpi/libacpi.h | 10 +++- tools/firmware/hvmloader/util.c | 24 ++++++++- 3 files changed, 84 insertions(+), 45 deletions(-)
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 v4 9/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 v4 10/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 v4:
* Added a suffix to iasl's -p option to work around a bug in older iasl versions where it drops everything after rightmost '.'.
.gitignore | 8 +++--- tools/firmware/hvmloader/Makefile | 11 +++++++- tools/firmware/hvmloader/acpi/Makefile | 48 ++++++++++++++++------------------ 3 files changed, 37 insertions(+), 30 deletions(-)
.gitignore +4 -4
@@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt tools/firmware/etherboot/gpxe/* tools/firmware/extboot/extboot.img tools/firmware/extboot/signrom -tools/firmware/hvmloader/acpi/mk_dsdt -tools/firmware/hvmloader/acpi/dsdt*.c -tools/firmware/hvmloader/acpi/dsdt_*cpu*.asl -tools/firmware/hvmloader/acpi/ssdt_*.h +tools/firmware/hvmloader/dsdt*.c +tools/firmware/hvmloader/dsdt_*.asl tools/firmware/hvmloader/hvmloader +tools/firmware/hvmloader/mk_dsdt tools/firmware/hvmloader/roms.h tools/firmware/hvmloader/roms.inc +tools/firmware/hvmloader/ssdt_*.h tools/firmware/rombios/BIOS-bochs-[^/]* tools/firmware/rombios/_rombios[^/]*_.c tools/firmware/rombios/rombios[^/]*.s
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 +23 -25
78 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 v4 10/21] acpi/hvmloader: Link ACPI object files directly
.gitignore tools/firmware/*bios/*bios*.txt · line 131
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
.gitignore +2
-4@@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt tools/firmware/etherboot/gpxe/* tools/firmware/extboot/extboot.img tools/firmware/extboot/signrom -tools/firmware/hvmloader/acpi/mk_dsdt -tools/firmware/hvmloader/acpi/dsdt*.c -tools/firmware/hvmloader/acpi/dsdt_*cpu*.asl -tools/firmware/hvmloader/acpi/ssdt_*.h +tools/firmware/hvmloader/dsdt*.c +tools/firmware/hvmloader/dsdt_*.asl
Aren't you wrongly dropping the *cpu part here?
tools/firmware/hvmloader/acpi/Makefile line 20
Quoted 12 lines
tools/firmware/hvmloader/acpi/Makefile +3
-3@@ -15,41 +15,45 @@ XEN_ROOT = $(CURDIR)/../../../.. include $(XEN_ROOT)/tools/firmware/Rules.mk -C_SRC-$(GPL) = build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c -C_SRC = build.c static_tables.c $(C_SRC-y) -OBJS = $(patsubst %.c,%.o,$(C_SRC)) +# Used as a workaround for a bug in some older iasl versions where +# the tool will ignore everything after last '.' in the path ('-p' argument) +TMP_SUFFIX = tmp__
Hmm, the comment leaves open what newer iasl does? I suppose it strips everything after the last . too, but only if that ones comes after the last path separator? It took me a moment to understand that no file with this suffix will ever be created, if my above summary is right. Please clarify this in the comment.
With these two minor issues addressed,
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 7 lines · On 20.09.16 at 02:19, <[email protected]> wrote:
Quoted 6 lines
tools/firmware/hvmloader/acpi/Makefile +0
-0@@ -15,41 +15,45 @@ XEN_ROOT = $(CURDIR)/../../../.. include $(XEN_ROOT)/tools/firmware/Rules.mk
Quoted 10 lines
tools/firmware/hvmloader/acpi/Makefile line 20
Quoted 6 lines
tools/firmware/hvmloader/acpi/Makefile +3
-3-C_SRC-$(GPL) = build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c -C_SRC = build.c static_tables.c $(C_SRC-y) -OBJS = $(patsubst %.c,%.o,$(C_SRC)) +# Used as a workaround for a bug in some older iasl versions where +# the tool will ignore everything after last '.' in the path ('-p' argument) +TMP_SUFFIX = tmp__Hmm, the comment leaves open what newer iasl does? I suppose it strips everything after the last . too, but only if that ones comes after the last path separator?
I think Boris's approach ensures that the last . always comes after the last path separator.
Quoted 3 lines
It took me a moment to understand
that no file with this suffix will ever be created, if my above summary is right. Please clarify this in the comment.
I'm not sure it's really helpful to put this TMP_SUFFIX thing in a make variable but maybe Jan prefers it that way.
In any case I think the choice of `tmp__' is rather odd. AFAICT the resulting iasl command lines look like this:
iasl -vs -p /path/to/here/blah.tmp__ -tc /path/to/here/blah.asl
I think `.dummy' would be a better string, if indeed it's a string which we expect always to be stripped, and not to appear in any filenames.
ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 13:29, <[email protected]> wrote:
Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 7 lines · On 20.09.16 at 02:19, <[email protected]> wrote:
Quoted 6 lines
tools/firmware/hvmloader/acpi/Makefile +0
-0@@ -15,41 +15,45 @@ XEN_ROOT = $(CURDIR)/../../../.. include $(XEN_ROOT)/tools/firmware/Rules.mkQuoted 10 lines
tools/firmware/hvmloader/acpi/Makefile line 20
Quoted 6 lines
tools/firmware/hvmloader/acpi/Makefile +3
-3-C_SRC-$(GPL) = build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c -C_SRC = build.c static_tables.c $(C_SRC-y) -OBJS = $(patsubst %.c,%.o,$(C_SRC)) +# Used as a workaround for a bug in some older iasl versions where +# the tool will ignore everything after last '.' in the path ('-p' argument) +TMP_SUFFIX = tmp__Hmm, the comment leaves open what newer iasl does? I suppose it strips everything after the last . too, but only if that ones comes after the last path separator?
I think Boris's approach ensures that the last . always comes after the last path separator.
Quoted 6 lines
Quoted 3 lines
It took me a moment to understand
that no file with this suffix will ever be created, if my above summary is right. Please clarify this in the comment.I'm not sure it's really helpful to put this
TMP_SUFFIXthing in a make variable but maybe Jan prefers it that way.
At least I didn't ask for it, and I'd be fine without.
Quoted 8 lines
In any case I think the choice of `tmp__' is rather odd. AFAICT the resulting iasl command lines look like this:
iasl -vs -p /path/to/here/blah.tmp__ -tc /path/to/here/blah.asl
I think `.dummy' would be a better string, if indeed it's a string which we expect always to be stripped, and not to appear in any filenames.
Another (currently later, but I'd prefer it to be moved ahead) patch uses this for actual temporary files.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 7 lines · On 21.09.16 at 13:29, <[email protected]> wrote:
Quoted 3 lines
I think `.dummy' would be a better string, if indeed it's a string which we expect always to be stripped, and not to appear in any filenames.
Another (currently later, but I'd prefer it to be moved ahead) patch uses this for actual temporary files.
OK, then I don't understand what's wrong with ".tmp" ...
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 13:38, <[email protected]> wrote:
Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 1 line · On 21.09.16 at 13:29, <[email protected]> wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I think `.dummy' would be a better string, if indeed it's a string which we expect always to be stripped, and not to appear in any filenames.
Another (currently later, but I'd prefer it to be moved ahead) patch uses this for actual temporary files.
OK, then I don't understand what's wrong with ".tmp" ...
So did I think when looking at the patch, but then I also thought (at least until I saw that actual files get created with that suffix) that it doesn't really matter. Boris?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 13:38, <[email protected]> wrote:
Jan Beulich writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 4 lines · On 21.09.16 at 13:29, <[email protected]> wrote:
Quoted 3 lines
I think `.dummy' would be a better string, if indeed it's a string which we expect always to be stripped, and not to appear in any filenames.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Another (currently later, but I'd prefer it to be moved ahead) patch uses this for actual temporary files.
OK, then I don't understand what's wrong with ".tmp" ...
So did I think when looking at the patch, but then I also thought (at least until I saw that actual files get created with that suffix) that it doesn't really matter. Boris?
I think there are two questions about using TMP_SUFFIX=tmp__
1. It is indeed used for two purposes --- one is to work around the bug and the other is to append to intermediate build files (that are later removed). There are two instances where I need to handle the bug and thus I use a variable and not a literal ".dummy". And since I already have (or, in this iteration of the series, will have in the later patch) TMP_SUFFIX I figured I'd use it here as well.
2. ".tmp__" vs ".tmp": Because the temporary files are generated not in tools/libacpi but in the directory of the libacpi user (such as libxl) it is possible that a Makefile there might use ".tmp' for its own purposes so I am trying here to minimize chances of a conflict. Maybe even ".tmp_acpi"?
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Boris Ostrovsky writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 5 lines
2. ".tmp__" vs ".tmp": Because the temporary files are generated not in
tools/libacpibut in the directory of the libacpi user (such as libxl) it is possible that aMakefilethere might use ".tmp' for its own purposes so I am trying here to minimize chances of a conflict. Maybe even ".tmp_acpi"?
Wait, the libxl makefiles are going to end up running iasl ?
If you end up making these files appear elsewhere then I think ".tmp" is fine if the first part of the filename is unique enough.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Quoted 7 lines · Ian Jackson
Boris Ostrovsky writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 5 lines
2. ".tmp__" vs ".tmp": Because the temporary files are generated not in
tools/libacpibut in the directory of the libacpi user (such as libxl) it is possible that aMakefilethere might use ".tmp' for its own purposes so I am trying here to minimize chances of a conflict. Maybe even ".tmp_acpi"?Wait, the libxl makefiles are going to end up running iasl ?
Not directly. There is a new target in libxl's Makefile:
acpi:
$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)
(ACPI_PATH is tools/libacpi)
Quoted 3 lines
If you end up making these files appear elsewhere then I think ".tmp" is fine if the first part of the filename is unique enough.
They are built in libxl directory, this is by design. If we were to build them in tools/libacpi then we may collide with other components (such as hvmloader) doing the build at the same time.
Keeping them in /tmp/mktemp -d, for example, does not quite work since we can't easily clean this up in case of an interrupt. (I tried this in an earlier version and it doesn't look good).
But the names are pretty unique (dsdt_<blah> or <ssdt_blah>).
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
Boris Ostrovsky writes ("Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly"):
Quoted 9 lines · Ian Jackson
Quoted 1 line
Wait, the libxl makefiles are going to end up running iasl ?
Not directly. There is a new target in libxl's
Makefile:acpi:
$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR)(
ACPI_PATHistools/libacpi)
Right.
Quoted 6 lines
Quoted 2 lines
If you end up making these files appear elsewhere then I think ".tmp" is fine if the first part of the filename is unique enough.
They are built in libxl directory, this is by design. If we were to build them in
tools/libacpithen we may collide with other components (such as hvmloader) doing the build at the same time.
I see. Yes, this is a good approach.
Quoted 3 lines
Keeping them in
/tmp/mktemp -d, for example, does not quite work since we can't easily clean this up in case of an interrupt. (I tried this in an earlier version and it doesn't look good).
What you have now is better.
Quoted 1 line
But the names are pretty unique (dsdt_<blah> or <
ssdt_blah>).
That's good.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 10/21] acpi/hvmloader: Link ACPI object files directly
In reply to Jan BeulichQuoted 14 lines · Jan Beulich
.gitignore tools/firmware/*bios/*bios*.txt · line 131
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
.gitignore +2
-4@@ -127,13 +127,13 @@ tools/firmware/*bios/*bios*.txt tools/firmware/etherboot/gpxe/* tools/firmware/extboot/extboot.img tools/firmware/extboot/signrom -tools/firmware/hvmloader/acpi/mk_dsdt -tools/firmware/hvmloader/acpi/dsdt*.c -tools/firmware/hvmloader/acpi/dsdt_*cpu*.asl -tools/firmware/hvmloader/acpi/ssdt_*.h +tools/firmware/hvmloader/dsdt*.c +tools/firmware/hvmloader/dsdt_*.aslAren't you wrongly dropping the *cpu part here?
(Missed this)
No: *cpu* was added earlier to keep hvmloader/acpi/dsdt_acpi_info.asl tracked by git but ignore generated files like hvmloader/acpi/dsdt_anycpu.asl. With this patch, those generated files will be created in hvmloader/ directory while dsdt_acpi_info.asl stays in hvmloader/acpi/ (and will eventually be moved to tools/libacpi).
Come think of it, hvmloader/dsdt* and hvmloader/ssdt* should all be ignored.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 11/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 v4:
* Include xen/memory.h in build.c
* lapic_id() returns uint8_t
tools/firmware/hvmloader/Makefile | 3 ++- tools/firmware/hvmloader/acpi/README | 16 ++++++++++++---- tools/firmware/hvmloader/acpi/build.c | 19 ++++++++++--------- tools/firmware/hvmloader/acpi/libacpi.h | 7 +++++++ tools/firmware/hvmloader/hvmloader.c | 2 +- tools/firmware/hvmloader/rombios.c | 2 +- tools/firmware/hvmloader/seabios.c | 5 +++-- tools/firmware/hvmloader/util.c | 15 +++++++++++++-- tools/firmware/rombios/32bit/Makefile | 2 +- tools/firmware/rombios/32bit/tcgbios/Makefile | 2 +- tools/firmware/rombios/32bit/util.h | 2 +- 11 files changed, 52 insertions(+), 23 deletions(-)
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 +10 -9
@@ -13,15 +13,13 @@* GNU Lesser General Public License for more details. */ +#include LIBACPI_STDUTILS #include "acpi2_0.h" #include "libacpi.h" #include "ssdt_s3.h" #include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" -#include "../config.h" -#include "../util.h" -#include "../vnuma.h" #include <xen/hvm/hvm_xs_strings.h> #include <xen/hvm/params.h> #include <xen/memory.h>
@@ -82,6 +80,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,const struct hvm_info_table *hvminfo = config->hvminfo;int i, sz; +if ( config->lapic_id ==NULL ) +return NULL ; + sz =sizeof (struct acpi_20_madt ); sz +=sizeof (struct acpi_20_madt_intsrcovr ) *16 ; sz +=sizeof (struct acpi_20_madt_ioapic );
@@ -98,7 +99,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, madt->header.oem_revision =ACPI_OEM_REVISION ; madt->header.creator_id =ACPI_CREATOR_ID ; madt->header.creator_revision =ACPI_CREATOR_REVISION ; - madt->lapic_addr =LAPIC_BASE_ADDRESS ; + madt->lapic_addr = config->lapic_base_address; madt->flags =ACPI_PCAT_COMPAT ;if ( config->table_flags &ACPI_HAS_IOAPIC )
@@ -117,7 +118,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, intsrcovr->gsi =2 ; intsrcovr->flags =0x0 ; } -else if (PCI_ISA_IRQ_MASK & (1U << i) ) +else if ( config->pci_isa_irq_mask & (1U << i) ) {/* PCI: active-low level-triggered. */ intsrcovr->gsi = i;
@@ -136,8 +137,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,memset (io_apic,0 ,sizeof (*io_apic)); io_apic->type =ACPI_IO_APIC ; io_apic->length =sizeof (*io_apic); - io_apic->ioapic_id =IOAPIC_ID ; - io_apic->ioapic_addr = ioapic_base_address; + io_apic->ioapic_id = config->ioapic_id; + io_apic->ioapic_addr = config->ioapic_base_address; lapic = (struct acpi_20_madt_lapic *)(io_apic +1 ); }
@@ -153,7 +154,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, lapic->length =sizeof (*lapic);/* Processor ID must match processor-object IDs in the DSDT. */ lapic->acpi_processor_id = i; - lapic->apic_id =LAPIC_ID (i); + lapic->apic_id = config->lapic_id (i); lapic->flags = (test_bit (i, hvminfo->vcpu_online) ?ACPI_LOCAL_APIC_ENABLED :0 ); lapic++;
@@ -241,7 +242,7 @@ static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt, processor->type =ACPI_PROCESSOR_AFFINITY ; processor->length =sizeof (*processor); processor->domain = config->numa.vcpu_to_vnode[i]; - processor->apic_id =LAPIC_ID (i); + processor->apic_id = config->lapic_id (i); processor->flags =ACPI_LOCAL_APIC_AFFIN_ENABLED ; processor++; }
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> #include <xen-tools/libs.h>
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
Re: [PATCH v4 11/21] acpi/hvmloader: Include file/paths adjustments
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
In prepearation to moving acpi sources into generally available libacpi:
1. Pass IOAPIC/LAPIC/PCI mask values via struct
acpi_config
2. Modify include files search paths to point to acpi directory
3. Macro-ise include file forbuild.cthat defines various utilities used by that file. Users of libacpi will be expected to define this macro when compilingbuild.cSigned-off-by Boris Ostrovsky <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 12/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}/Makefile | 2 +-
tools/{firmware/hvmloader/acpi => libacpi}/README | 0
tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h | 0
tools/{firmware/hvmloader/acpi => libacpi}/build.c | 0
.../hvmloader/acpi => libacpi}/dsdt_acpi_info.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/gpl/COPYING | 0
tools/{firmware/hvmloader/acpi => libacpi}/gpl/dsdt.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h | 0
tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c | 0
tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl | 0
tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c | 0
19 files changed, 13 insertions(+), 10 deletions(-)
rename tools/{firmware/hvmloader/acpi => libacpi}/Makefile (98%)
rename tools/{firmware/hvmloader/acpi => libacpi}/README (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/acpi2_0.h (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/build.c (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/dsdt_acpi_info.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/gpl/COPYING (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/gpl/dsdt.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/libacpi.h (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/mk_dsdt.c (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_pm.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s3.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_s4.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/ssdt_tpm.asl (100%)
rename tools/{firmware/hvmloader/acpi => libacpi}/static_tables.c (100%)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/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 # Used as a workaround for a bug in some older iasl versions where
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_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/dsdt.asl renamed from tools/firmware/hvmloader/acpi/gpl/dsdt.asl +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 v4 13/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 v4 14/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
@@ -22,7 +22,7 @@ TMP_SUFFIX = tmp__ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt C_SRC-$(GPL) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c -C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, $(C_SRC-y)) +C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_pvh.c $(C_SRC-y)) H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h) vpath iasl $(PATH)
@@ -49,6 +49,11 @@ $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: gpl/dsdt.asl $(MK_DSDT) $(MK_DSDT) --debug=$(debug) --maxcpu $* >> $@ endif +$(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT) + printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@ + cat dsdt_acpi_info.asl >> $@ + $(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@ + $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@
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
Re: [PATCH v4 14/21] libacpi: Build DSDT for PVH guests
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
PVH guests require DSDT with only ACPI INFO (Xen-specific) and Processor objects. We separate ASL's ACPI INFO definition into dsdt_acpi_info.asl so that it can be included in ASLs for both HVM and PVH2.
Signed-off-by Boris Ostrovsky <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 15/21 acpi: Makefile should better tolerate interrupts
In reply to Boris OstrovskyIntermediate stages of building a target should be made with temporary files that are copied to final target in the end.
---
Changes in v4:
* Instead of storing those intermediate files in /tmp keep then locally by adding TMP_SUFFIX to target.
tools/libacpi/Makefile | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
tools/libacpi/Makefile +18 -12
@@ -15,7 +15,8 @@ XEN_ROOT = $(CURDIR)/../.. include $(XEN_ROOT)/tools/firmware/Rules.mk -# Used as a workaround for a bug in some older iasl versions where +# Suffix for temporary files. +# Also used as a workaround for a bug in some older iasl versions where # the tool will ignore everything after last '.' in the path ('-p' argument) TMP_SUFFIX = tmp__
@@ -38,26 +39,30 @@ $(MK_DSDT): mk_dsdt.c ifeq ($(GPL),y) $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: gpl/dsdt.asl $(MK_DSDT) - awk 'NR > 1 {print s} {s=$$0}' $< > $@ - cat dsdt_acpi_info.asl >> $@ - $(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@ + awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) + $(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ # NB. awk invocation is a portable alternative to 'head -n -1' $(ACPI_BUILD_DIR)/dsdt_%cpu.asl: gpl/dsdt.asl $(MK_DSDT) - awk 'NR > 1 {print s} {s=$$0}' $< > $@ - cat dsdt_acpi_info.asl >> $@ - $(MK_DSDT) --debug=$(debug) --maxcpu $* >> $@ + awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) + cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) + $(MK_DSDT) --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ endif $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT) - printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@ - cat dsdt_acpi_info.asl >> $@ - $(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@ + printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@.$(TMP_SUFFIX) + cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) + $(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl - sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@ - echo "int $*_len=sizeof($*);" >>$@ + sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@.$(TMP_SUFFIX) + echo "int $*_len=sizeof($*);" >>$@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex) iasl:
@@ -70,6 +75,7 @@ iasl: clean: rm -fr $(C_SRC) $(H_SRC) $(MK_DSDT) $(patsubst %.c,%.asl,$(C_SRC)) + rm -f $(C_SRC:=.$(TMP_SUFFIX)) $(patsubst %.c,%.hex,$(C_SRC)) $(patsubst %.c,%.aml,$(C_SRC)) distclean: clean
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 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 v4 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 v4 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 v4 19/21 ilibxl: 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
Re: [PATCH v4 19/21] ilibxl: Initialize domain build info before calling libxl__domain_make
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
Btw - mind dropping the odd leading i from the subject?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 20/21 libxl/acpi: Build ACPI tables for HVMlite guests
In reply to Boris Ostrovsky---
Changes in v4:
* Remove allocation-specific fields from struct acpi_ctxt and use an enclosing struct libxl_acpi_ctxt.
* Use private struct hvminfo (to deal with constified struct acpi_config->hvminfo)
.gitignore | 12 ++- tools/libacpi/build.c | 7 +- tools/libacpi/libacpi.h | 6 +- tools/libxl/Makefile | 18 +++- tools/libxl/libxl_arch.h | 3 + tools/libxl/libxl_x86.c | 30 ++++-- tools/libxl/libxl_x86_acpi.c | 243 +++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_x86_acpi.h | 35 +++++++ 8 files changed, 334 insertions(+), 20 deletions(-) create mode 100644 tools/libxl/libxl_x86_acpi.c create mode 100644 tools/libxl/libxl_x86_acpi.h
.gitignore +8 -4
@@ -173,15 +173,19 @@ tools/include/xen/* tools/include/xen-xsm/* tools/include/xen-foreign/*.(c|h|size) tools/include/xen-foreign/checker -tools/libxl/libxlu_cfg_y.output +tools/libxl/_libxl.api-for-check +tools/libxl/*.api-ok tools/libxl/*.pc tools/libxl/*.pc.in -tools/libxl/xl +tools/libxl/dsdt*.c +tools/libxl/dsdt_*.asl +tools/libxl/libxlu_cfg_y.output +tools/libxl/mk_dsdt +tools/libxl/ssdt_*.h tools/libxl/testenum tools/libxl/testenum.c tools/libxl/tmp.* -tools/libxl/_libxl.api-for-check -tools/libxl/*.api-ok +tools/libxl/xl tools/misc/cpuperf/cpuperf-perfcntr tools/misc/cpuperf/cpuperf-xen tools/misc/xc_shadow
tools/libacpi/build.c +4 -3
@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> #include <xen/hvm/hvm_xs_strings.h> #include <xen/hvm/params.h> #include <xen/memory.h>
@@ -496,7 +497,7 @@ static int new_vm_gid(struct acpi_ctxt *ctxt,return 1 ; } -void acpi_build_tables (struct acpi_ctxt *ctxt,struct acpi_config *config) +int acpi_build_tables (struct acpi_ctxt *ctxt,struct acpi_config *config) {struct acpi_info *acpi_info;struct acpi_20_rsdp *rsdp;
@@ -631,11 +632,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)if ( !new_vm_gid (ctxt, config, acpi_info) ) goto oom; -return ; +return 0 ; oom:printf ("unable to build ACPI tables: out of memory\n" ); - +return -1 ; }/*
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 +17 -1
@@ -75,7 +75,21 @@ else LIBXL_OBJS-y += libxl_no_colo.o endif -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o +ACPI_PATH = $(XEN_ROOT)/tools/libacpi +ACPI_FILES = dsdt_pvh.c +ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o +$(ACPI_FILES): acpi +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\" +vpath build.c $(ACPI_PATH)/ +vpath static_tables.c $(ACPI_PATH)/ +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS) + +.PHONY: acpi +acpi: + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) +-include acpi + +LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o ifeq ($(CONFIG_NetBSD),y)
@@ -167,6 +181,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL) $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it. libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools # include libacpi/x86.h +libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
@@ -309,6 +324,7 @@ clean: $(RM) -f testidl.c.new testidl.c *.api-ok $(RM) -f xenlight.pc $(RM) -f xlutil.pc + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean distclean: clean $(RM) -f xenlight.pc.in xlutil.pc.in
tools/libxl/libxl_arch.h +3 -0
@@ -66,6 +66,9 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,#define LAPIC_BASE_ADDRESS 0xfee00000 +int libxl__dom_load_acpi (libxl__gc *gc, +const libxl_domain_build_info *b_info, +struct xc_dom_image *dom);#endif #endif
tools/libxl/libxl_x86.c +21 -9
@@ -8,15 +8,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, xc_domain_configuration_t *xc_config) { -if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_HVM && - d_config->b_info.device_model_version != -LIBXL_DEVICE_MODEL_VERSION_NONE ) { -/* HVM domains with a device model. */ - xc_config->emulation_flags =XEN_X86_EMU_ALL ; - }else { -/* PV or HVM domains without a device model. */ +if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_HVM ) { +if (d_config->b_info.device_model_version != +LIBXL_DEVICE_MODEL_VERSION_NONE ) { + xc_config->emulation_flags =XEN_X86_EMU_ALL ; + }else if (libxl_defbool_val (d_config->b_info.u.hvm.apic)) { +/* +* HVM guests without device model may want +* to have LAPIC emulation. +*/ + xc_config->emulation_flags =XEN_X86_EMU_LAPIC ; + } + }else xc_config->emulation_flags =0 ; - }return 0 ; }
@@ -366,7 +370,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,libxl_domain_build_info *info, struct xc_dom_image *dom) { -return 0 ; + int ret = 0; + +if ((info->type ==LIBXL_DOMAIN_TYPE_HVM ) && + (info->device_model_version ==LIBXL_DEVICE_MODEL_VERSION_NONE )) { +if ( (ret =libxl__dom_load_acpi (gc, info, dom)) !=0 ) +LOGE (ERROR ,"libxl_dom_load_acpi failed" ); + } + +return ret; }/* Return 0 on success, ERROR_* on failure. */
tools/libxl/libxl_x86_acpi.c new file +243 -0
243 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 !!(((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 v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
Signed-off-by Boris Ostrovsky <[email protected]>
libacpi parts
albeit ...
tools/libacpi/build.c line 23
Quoted 7 lines
tools/libacpi/build.c +1
-0@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h>
... I don't really see why this becomes necessary here. Please clarify.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 7 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
Signed-off-by Boris Ostrovsky <[email protected]>libacpi parts
Acked-by Jan Beulich <[email protected]>albeit ...
Quoted 9 lines
tools/libacpi/build.c line 23
Quoted 7 lines
tools/libacpi/build.c +1
-0@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> ... I don't really see why this becomes necessary here. Please clarify.
xen/hvm/hvm_info_table.h in included by hvmloader/util.h so we haven't needed this include until now.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 17:09, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
tools/libacpi/build.c line 23
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/libacpi/build.c +1
-0@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> ... I don't really see why this becomes necessary here. Please clarify.
Quoted 2 lines
xen/hvm/hvm_info_table.hin included byhvmloader/util.hso we haven't needed this include until now.
But you're not removing any inclusion here. Does that addition perhaps belong elsewhere?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 17:09, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
tools/libacpi/build.c line 23
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/libacpi/build.c +1
-0@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> ... I don't really see why this becomes necessary here. Please clarify.
Quoted 4 lines
Quoted 2 lines
xen/hvm/hvm_info_table.hin included byhvmloader/util.hso we haven't needed this include until now.But you're not removing any inclusion here. Does that addition perhaps belong elsewhere?
I suppose I can add it to libxl_x86_acpi.h (and remove from libxl_x86_acpi.c) to be consistent with how it is included by util.h
OTOH, include files that we pass as -DLIBACPI_STDUTILS=\"$(CURDIR)/<includefile.h.> are intended to provide declarations for things that are specific to the caller, not to Xen in general.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 17:34, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 17:09, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
tools/libacpi/build.c line 23
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/libacpi/build.c +1
-0@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> ... I don't really see why this becomes necessary here. Please clarify.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
xen/hvm/hvm_info_table.hin included byhvmloader/util.hso we haven't needed this include until now.But you're not removing any inclusion here. Does that addition perhaps belong elsewhere?
I suppose I can add it to
libxl_x86_acpi.h(and remove fromlibxl_x86_acpi.c) to be consistent with how it is included byutil.h
That doesn't answer my question (by "elsewhere" I meant another, earlier patch). By the time stuff got moved to tools/ you can't possibly rely on util.h inclusion here anymore.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 17:34, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 17:09, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
tools/libacpi/build.c line 23
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 20.09.16 at 02:19, <[email protected]> wrote:
tools/libacpi/build.c +1
-0@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> ... I don't really see why this becomes necessary here. Please clarify.
xen/hvm/hvm_info_table.hin included byhvmloader/util.hso we haven't needed this include until now.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
But you're not removing any inclusion here. Does that addition perhaps belong elsewhere?
I suppose I can add it to
libxl_x86_acpi.h(and remove fromlibxl_x86_acpi.c) to be consistent with how it is included byutil.hThat doesn't answer my question (by "elsewhere" I meant another, earlier patch). By the time stuff got moved to
tools/you can't possibly rely onutil.hinclusion here anymore.
Patch 11 ("acpi/hvmloader: Include file/paths adjustments") may be a better place to make this change.
I don't understand though why we can't rely on util.h after the move. hvmloader will continue including it via -DLIBACPI_STDUTILS=\"$(CURDIR)/util.h. At that point (and until this patch) hvmloader is the only user of libacpi and including hvm_info_table.h via util.h works fine (but, as I said in the previous message, is not logical).
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 21.09.16 at 18:38, <[email protected]> wrote:
I don't understand though why we can't rely on
util.hafter the move.
Once you move the component, it should be self-contained.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
In reply to Boris OstrovskyQuoted 1 line · Boris Ostrovsky
Signed-off-by Boris Ostrovsky <[email protected]>
The code mostly looks good. Some nits below.
Quoted 120 lines
---
Changes in v4:
* Remove allocation-specific fields from structacpi_ctxtand use an enclosing structlibxl_acpi_ctxt.
* Use private struct hvminfo (to deal with constified structacpi_config->hvminfo).gitignore | 12 ++- tools/libacpi/build.c | 7 +- tools/libacpi/libacpi.h | 6 +- tools/libxl/Makefile | 18 +++- tools/libxl/libxl_arch.h | 3 + tools/libxl/libxl_x86.c | 30 ++++-- tools/libxl/libxl_x86_acpi.c | 243 +++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_x86_acpi.h | 35 +++++++ 8 files changed, 334 insertions(+), 20 deletions(-) create mode 100644 tools/libxl/libxl_x86_acpi.c create mode 100644 tools/libxl/libxl_x86_acpi.h.gitignore +8
-4@@ -173,15 +173,19 @@ tools/include/xen/* tools/include/xen-xsm/* tools/include/xen-foreign/*.(c|h|size) tools/include/xen-foreign/checker -tools/libxl/libxlu_cfg_y.output +tools/libxl/_libxl.api-for-check +tools/libxl/*.api-ok tools/libxl/*.pc tools/libxl/*.pc.in -tools/libxl/xl +tools/libxl/dsdt*.c +tools/libxl/dsdt_*.asl +tools/libxl/libxlu_cfg_y.output +tools/libxl/mk_dsdt +tools/libxl/ssdt_*.h tools/libxl/testenum tools/libxl/testenum.c tools/libxl/tmp.* -tools/libxl/_libxl.api-for-check -tools/libxl/*.api-ok +tools/libxl/xl tools/misc/cpuperf/cpuperf-perfcntr tools/misc/cpuperf/cpuperf-xen tools/misc/xc_shadowtools/libacpi/build.c +4
-3@@ -20,6 +20,7 @@#include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include <xen/hvm/hvm_info_table.h> #include <xen/hvm/hvm_xs_strings.h> #include <xen/hvm/params.h> #include <xen/memory.h> @@ -496,7 +497,7 @@ static int new_vm_gid(struct acpi_ctxt *ctxt,return 1 ; } -void acpi_build_tables (struct acpi_ctxt *ctxt,struct acpi_config *config) +int acpi_build_tables (struct acpi_ctxt *ctxt,struct acpi_config *config) {struct acpi_info *acpi_info;struct acpi_20_rsdp *rsdp;@@ -631,11 +632,11 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config)if ( !new_vm_gid (ctxt, config, acpi_info) ) goto oom; -return ; +return 0 ; oom:printf ("unable to build ACPI tables: out of memory\n" ); - +return -1 ; }/* 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 +3
-1@@ -75,7 +75,21 @@ else LIBXL_OBJS-y += libxl_no_colo.o endif -LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o +ACPI_PATH = $(XEN_ROOT)/tools/libacpi +ACPI_FILES = dsdt_pvh.c +ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o
tools/libxl/Makefile else · line 90
Quoted 10 lines
tools/libxl/Makefile +10
-0+$(ACPI_FILES): acpi +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\" +vpath build.c $(ACPI_PATH)/ +vpath static_tables.c $(ACPI_PATH)/ +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS) + +.PHONY: acpi +acpi: + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) +-include acpi
Useless include?
Quoted 26 lines
tools/libxl/Makefile +4
-0+ +LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o ifeq ($(CONFIG_NetBSD),y)@@ -167,6 +181,7 @@ $(XL_OBJS): CFLAGS += $(CFLAGS_XL) $(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it. libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools # include libacpi/x86.h +libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)@@ -309,6 +324,7 @@ clean: $(RM) -f testidl.c.new testidl.c *.api-ok $(RM) -f xenlight.pc $(RM) -f xlutil.pc + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean distclean: clean $(RM) -f xenlight.pc.in xlutil.pc.intools/libxl/libxl_arch.h +0
-0
tools/libxl/libxl_arch.h int libxl__arch_domain_construct_memmap(libxl__gc *gc, · line 71
Quoted 6 lines
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);
Use space instead of tab please.
Quoted 23 lines
tools/libxl/libxl_arch.h +0
-0#endif #endif tools/libxl/libxl_x86.c +5
-7@@ -8,15 +8,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, xc_domain_configuration_t *xc_config) { -if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_HVM && - d_config->b_info.device_model_version != -LIBXL_DEVICE_MODEL_VERSION_NONE ) { -/* HVM domains with a device model. */ - xc_config->emulation_flags =XEN_X86_EMU_ALL ; - }else { -/* PV or HVM domains without a device model. */ +if (d_config->c_info.type ==LIBXL_DOMAIN_TYPE_HVM ) { +if (d_config->b_info.device_model_version != +LIBXL_DEVICE_MODEL_VERSION_NONE ) { + xc_config->emulation_flags =XEN_X86_EMU_ALL ; + }else if (libxl_defbool_val (d_config->b_info.u.hvm.apic)) {
tools/libxl/libxl_x86.c int libxl__arch_domain_prepare_config(libxl__gc *gc, · line 24
Quoted 10 lines
tools/libxl/libxl_x86.c +7
-1+/* +* HVM guests without device model may want +* to have LAPIC emulation. +*/ + xc_config->emulation_flags =XEN_X86_EMU_LAPIC ; + } + }else xc_config->emulation_flags =0 ; - }
Coding style nit: We now forbid an else branch without braces. Please add them here.
tools/libxl/libxl_x86.c int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, · line 373
Quoted 8 lines
tools/libxl/libxl_x86.c +1
-1return 0 ; }@@ -366,7 +370,15 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc,libxl_domain_build_info *info, struct xc_dom_image *dom) { -return 0 ; + int ret = 0;
Use rc please.
tools/libxl/libxl_x86.c int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, · line 377
Quoted 4 lines
tools/libxl/libxl_x86.c +4
-0+ +if ((info->type ==LIBXL_DOMAIN_TYPE_HVM ) && + (info->device_model_version ==LIBXL_DEVICE_MODEL_VERSION_NONE )) { +if ( (ret =libxl__dom_load_acpi (gc, info, dom)) !=0 )
Extraneous spaces here. And lift ret= bit out of if statement.
Quoted 92 lines
tools/libxl/libxl_x86.c +4
-0+LOGE (ERROR ,"libxl_dom_load_acpi failed" ); + } + +return ret; }/* Return 0 on success, ERROR_* on failure. */ tools/libxl/libxl_x86_acpi.c new file +79
-0@@ -0,0 +1,243 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. +*/ + +#include "libxl_internal.h" +#include "libxl_arch.h" +#include <xen/hvm/hvm_info_table.h> +#include <xen/hvm/e820.h> +#include "libacpi/libacpi.h" + +#include <xc_dom.h> + +/* Number of pages holding ACPI tables */ +#define NUM_ACPI_PAGES 16 +/* Store RSDP in the last 64 bytes of BIOS RO memory */ +#define RSDP_ADDRESS (0x100000 - 64) +#define ACPI_INFO_PHYSICAL_ADDRESS 0xfc000000 + +struct libxl_acpi_ctxt { +struct acpi_ctxt c; + +unsigned int page_size; +unsigned int page_shift; + +/* Memory allocator */ +unsigned long alloc_base_paddr; +unsigned long alloc_base_vaddr; +unsigned long alloc_currp; +unsigned long alloc_end; +}; + +extern const unsigned char dsdt_pvh[]; +extern const unsigned int dsdt_pvh_len; + +/* Assumes contiguous physical space */ +static unsigned long virt_to_phys (struct acpi_ctxt *ctxt,void *v) +{ +struct libxl_acpi_ctxt *libxl_ctxt = + CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c); + +return (((unsigned long )v - libxl_ctxt->alloc_base_vaddr) + + libxl_ctxt->alloc_base_paddr); +} + +static void *mem_alloc (struct acpi_ctxt *ctxt, +uint32_t size,uint32_t align) +{ +struct libxl_acpi_ctxt *libxl_ctxt = + CONTAINER_OF(ctxt, struct libxl_acpi_ctxt, c); +unsigned long s, e; + +/* Align to at least 16 bytes. */ +if (align <16 ) + align =16 ; + + s = (libxl_ctxt->alloc_currp + align) & ~((unsigned long )align -1 ); + e = s + size -1 ; + +/* TODO: Reallocate memory */ +if ((e < s) || (e >= libxl_ctxt->alloc_end)) +return NULL ; + +while (libxl_ctxt->alloc_currp >> libxl_ctxt->page_shift != + e >> libxl_ctxt->page_shift) + libxl_ctxt->alloc_currp += libxl_ctxt->page_size; + + libxl_ctxt->alloc_currp = e; + +return (void *)s;
tools/libxl/libxl_x86_acpi.c line 89
Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10
-0+} + +static void acpi_mem_free (struct acpi_ctxt *ctxt, +void *v,uint32_t size) +{ +} + +static uint8_t acpi_lapic_id (unsigned cpu) +{ +return cpu *2 ;
Is this in accordance with hardware spec?
tools/libxl/libxl_x86_acpi.c line 96
Quoted 7 lines
tools/libxl/libxl_x86_acpi.c new file +7
-0+} + +static int init_acpi_config (libxl__gc *gc, +struct xc_dom_image *dom, +const libxl_domain_build_info *b_info, +struct acpi_config *config) +{
Use goto style error handling in this function please.
tools/libxl/libxl_x86_acpi.c line 108
Quoted 12 lines
tools/libxl/libxl_x86_acpi.c new file +12
-0+xc_interface *xch = dom->xch; +uint32_t domid = dom->guest_domid; +xc_dominfo_t info; +struct hvm_info_table *hvminfo; +int i, rc; + + config->dsdt_anycpu = config->dsdt_15cpu = dsdt_pvh; + config->dsdt_anycpu_len = config->dsdt_15cpu_len = dsdt_pvh_len; + + rc =xc_domain_getinfo (xch, domid,1 , &info); +if (rc <0 ) { +LOG (ERROR ,"%s: getdomaininfo failed (rc=%d)" , __FUNCTION__, rc);
No need to have __FUNCTION__ -- LOG already prints that.
Quoted 29 lines
tools/libxl/libxl_x86_acpi.c new file +29
-0+return rc; + } + + hvminfo =libxl__zalloc (gc,sizeof (*hvminfo)); + + hvminfo->apic_mode =libxl_defbool_val (b_info->u.hvm.apic); + +if (dom->nr_vnodes) { +unsigned int *vcpu_to_vnode, *vdistance; +struct xen_vmemrange *vmemrange; +struct acpi_numa *numa = &config->numa; + + rc =xc_domain_getvnuma (xch, domid, &numa->nr_vnodes, + &numa->nr_vmemranges, + &hvminfo->nr_vcpus,NULL ,NULL ,NULL ); +if (rc) { +LOG (ERROR ,"%s: xc_domain_getvnuma failed (rc=%d)" , + __FUNCTION__, rc); +return rc; + } + + vmemrange =libxl__zalloc (gc, dom->nr_vmemranges *sizeof (*vmemrange)); + vdistance =libxl__zalloc (gc, dom->nr_vnodes *sizeof (*vdistance)); + vcpu_to_vnode =libxl__zalloc (gc, hvminfo->nr_vcpus * +sizeof (*vcpu_to_vnode)); + rc =xc_domain_getvnuma (xch, domid, &numa->nr_vnodes, + &numa->nr_vmemranges, &hvminfo->nr_vcpus, + vmemrange, vdistance, vcpu_to_vnode); +if (rc) {
tools/libxl/libxl_x86_acpi.c line 147
Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10
-0+LOG (ERROR ,"%s: xc_domain_getvnuma failed (rc=%d)" , + __FUNCTION__, rc); +return rc; + } + numa->vmemrange = vmemrange; + numa->vdistance = vdistance; + numa->vcpu_to_vnode = vcpu_to_vnode; + } +else + hvminfo->nr_vcpus = info.max_vcpu_id +1 ;
"else" should be right after "}" and please add braces.
Quoted 15 lines
tools/libxl/libxl_x86_acpi.c new file +15
-0+ +for (i =0 ; i < hvminfo->nr_vcpus; i++) + hvminfo->vcpu_online[i /8 ] |=1 << (i &7 ); + + config->hvminfo = hvminfo; + + config->lapic_base_address =LAPIC_BASE_ADDRESS ; + config->lapic_id = acpi_lapic_id; + +return 0 ; +} + +int libxl__dom_load_acpi (libxl__gc *gc, +const libxl_domain_build_info *b_info, +struct xc_dom_image *dom)
tools/libxl/libxl_x86_acpi.c line 172
Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10
-0+{ +struct acpi_config config = {0 }; +struct libxl_acpi_ctxt libxl_ctxt; +int rc, acpi_pages_num; +void *acpi_pages; +unsigned long page_mask; + +if ((b_info->type !=LIBXL_DOMAIN_TYPE_HVM ) || + (b_info->device_model_version !=LIBXL_DEVICE_MODEL_VERSION_NONE )) +return 0 ;
Please don't use mixed-style error handling.
Quoted 53 lines
tools/libxl/libxl_x86_acpi.c new file +53
-0+ + libxl_ctxt.page_size =XC_DOM_PAGE_SIZE (dom); + libxl_ctxt.page_shift =XC_DOM_PAGE_SHIFT (dom); + page_mask = (1UL << libxl_ctxt.page_shift) -1 ; + + libxl_ctxt.c.mem_ops.alloc = mem_alloc; + libxl_ctxt.c.mem_ops.v2p = virt_to_phys; + libxl_ctxt.c.mem_ops.free = acpi_mem_free; + + rc =init_acpi_config (gc, dom, b_info, &config); +if (rc) { +LOG (ERROR ,"%s: init_acpi_config failed (rc=%d)" , __FUNCTION__, rc); +return rc; + } + + config.rsdp = (unsigned long )libxl__malloc (gc, libxl_ctxt.page_size); + config.infop = (unsigned long )libxl__malloc (gc, libxl_ctxt.page_size); +/* Pages to hold ACPI tables */ + acpi_pages =libxl__malloc (gc, (NUM_ACPI_PAGES +1 ) * + libxl_ctxt.page_size); + +/* +* Set up allocator memory. +* Start next to acpi_info page to avoid fracturing e820. +*/ + libxl_ctxt.alloc_base_paddr =ACPI_INFO_PHYSICAL_ADDRESS + + libxl_ctxt.page_size; + libxl_ctxt.alloc_base_vaddr = libxl_ctxt.alloc_currp = + (unsigned long )acpi_pages; + libxl_ctxt.alloc_end = (unsigned long )acpi_pages + + (NUM_ACPI_PAGES * libxl_ctxt.page_size); + +/* Build the tables. */ + rc =acpi_build_tables (&libxl_ctxt.c, &config); +if (rc) { +LOG (ERROR ,"%s: acpi_build_tables failed with %d" , + __FUNCTION__, rc); + goto out; + } + +/* Calculate how many pages are needed for the tables. */ + acpi_pages_num = + ((libxl_ctxt.alloc_currp - (unsigned long )acpi_pages) + >> libxl_ctxt.page_shift) + + ((libxl_ctxt.alloc_currp & page_mask) ?1 :0 ); + + dom->acpi_modules[0 ].data = (void *)config.rsdp; + dom->acpi_modules[0 ].length =64 ; + dom->acpi_modules[0 ].guest_addr_out =RSDP_ADDRESS ; + + dom->acpi_modules[1 ].data = (void *)config.infop; + dom->acpi_modules[1 ].length =4096 ; + dom->acpi_modules[1 ].guest_addr_out =ACPI_INFO_PHYSICAL_ADDRESS ;
tools/libxl/libxl_x86_acpi.c line 235
Quoted 10 lines
tools/libxl/libxl_x86_acpi.c new file +10
-0+ + dom->acpi_modules[2 ].data = acpi_pages; + dom->acpi_modules[2 ].length = acpi_pages_num << libxl_ctxt.page_shift; + dom->acpi_modules[2 ].guest_addr_out =ACPI_INFO_PHYSICAL_ADDRESS + + libxl_ctxt.page_size; + +out: + +return rc; +
Extraneous line.
Quoted 52 lines
tools/libxl/libxl_x86_acpi.c new file +8
-0+} +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ 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 !!(((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 · 1 line
1.8.3.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 9 lines · Wei Liu
Quoted 9 lines
tools/libxl/Makefile +0
-0@@ -75,7 +75,21 @@ else LIBXL_OBJS-y += libxl_no_colo.o endif
Quoted 15 lines
Quoted 4 lines
tools/libxl/Makefile +3
-1-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.otools/libxl/Makefile else · line 90
Quoted 10 lines
tools/libxl/Makefile +10
-0+$(ACPI_FILES): acpi +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\" +vpath build.c $(ACPI_PATH)/ +vpath static_tables.c $(ACPI_PATH)/ +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS) + +.PHONY: acpi +acpi: + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) +-include acpiUseless include?
Hmm... I thought there was a reason I put this here but I can't remember now.
Quoted 6 lines
tools/libxl/Makefile else · line 94
Quoted 5 lines
tools/libxl/Makefile +4
-0+ +static uint8_t acpi_lapic_id(unsigned cpu) +{ + return cpu * 2;Is this in accordance with hardware spec?
That's how we (Xen) encode APIC IDs for guests. For example, see vlapic_reset().
Quoted 7 lines
Quoted 7 lines
tools/libxl/Makefile +7
-0+ +int libxl__dom_load_acpi(libxl__gc *gc, + const libxl_domain_build_info *b_info, + struct xc_dom_image *dom) +{ + struct acpi_config config = {0}; + struct libxl_acpi_ctxt libxl_ctxt;
Quoted 8 lines
tools/libxl/Makefile
Quoted 7 lines
tools/libxl/Makefile +7
-0+ int rc, acpi_pages_num; + void *acpi_pages; + unsigned long page_mask; + + if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) || + (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE)) + return 0;Please don't use mixed-style error handling.
Not sure I understand what you are asking for. You want 'return rc'? Or 'goto out'?
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 20/21] libxl/acpi: Build ACPI tables for HVMlite guests
Quoted 30 lines · Boris Ostrovsky
Quoted 9 lines · Wei Liu
Quoted 9 lines
tools/libxl/Makefile +0
-0@@ -75,7 +75,21 @@ else LIBXL_OBJS-y += libxl_no_colo.o endifQuoted 15 lines
Quoted 4 lines
tools/libxl/Makefile +3
-1-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.otools/libxl/Makefile else · line 90
Quoted 10 lines
tools/libxl/Makefile +10
-0+$(ACPI_FILES): acpi +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\" +vpath build.c $(ACPI_PATH)/ +vpath static_tables.c $(ACPI_PATH)/ +LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS) + +.PHONY: acpi +acpi: + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) +-include acpiUseless include?
Hmm... I thought there was a reason I put this here but I can't remember now.
Quoted 1 line
Quoted 9 lines
Quoted 5 lines
tools/libxl/Makefile else · line 94
Quoted 4 lines
tools/libxl/Makefile +4
-0+ +static uint8_t acpi_lapic_id(unsigned cpu) +{ + return cpu * 2;Is this in accordance with hardware spec?
That's how we (Xen) encode APIC IDs for guests. For example, see
vlapic_reset().
OK.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
tools/libxl/Makefile +7
-0+ +int libxl__dom_load_acpi(libxl__gc *gc, + const libxl_domain_build_info *b_info, + struct xc_dom_image *dom) +{ + struct acpi_config config = {0}; + struct libxl_acpi_ctxt libxl_ctxt;Quoted 8 lines
tools/libxl/Makefile
Quoted 7 lines
tools/libxl/Makefile +7
-0+ int rc, acpi_pages_num; + void *acpi_pages; + unsigned long page_mask; + + if ((b_info->type != LIBXL_DOMAIN_TYPE_HVM) || + (b_info->device_model_version != LIBXL_DEVICE_MODEL_VERSION_NONE)) + return 0;Please don't use mixed-style error handling.
Quoted 3 lines
Not sure I understand what you are asking for. You want 'return rc'? Or 'goto out'?
goto out please.
Quoted 2 lines
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 21/21 libxc/xc_dom_core: Copy ACPI tables to guest space
In reply to Boris OstrovskyLoad ACPI modules into guest space
---
Changes in v4:
* Style updates
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
Re: [PATCH v4 21/21] libxc/xc_dom_core: Copy ACPI tables to guest space
Quoted 3 lines · Boris Ostrovsky
Load ACPI modules into guest space
Signed-off-by Boris Ostrovsky <[email protected]>
Code-wise:
There are still some inconsistencies in coding style.
Quoted 22 lines
---
Changes in v4:
* Style updatestools/libxc/xc_dom_core.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+)tools/libxc/xc_dom_core.c +7
-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;
tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1059
Quoted 10 lines
tools/libxc/xc_dom_core.c +10
-0+unsigned long idx; +unsigned int first_high_idx = (4 <<30 ) >>PAGE_SHIFT ;/* 4GB */ + +for ( ; num_pages; num_pages--, extents++ ) + { + +if (xc_domain_populate_physmap (xch, domid,1 ,0 ,0 , extents) ==1 ) +continue ; + +if (dom->highmem_end)
Here.
Quoted 4 lines
tools/libxc/xc_dom_core.c +4
-0+ { + idx = --dom->highmem_end; +if ( idx == first_high_idx ) + dom->highmem_end =0 ;
tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1073
Quoted 10 lines
tools/libxc/xc_dom_core.c +10
-0+ } +else + { + idx = --dom->lowmem_end; + } + + rc =xc_domain_add_to_physmap (xch, domid, + XENMAPSPACE_gmfn, + idx, *extents); +if (rc)
Here.
Quoted 20 lines
tools/libxc/xc_dom_core.c +20
-0+return rc; + } + +return 0 ; +} + +static int xc_dom_load_acpi (struct xc_dom_image *dom) +{ +int j, i =0 ; +unsigned num_pages; +xen_pfn_t *extents, base; +void *ptr; + +while ( (i <MAX_ACPI_MODULES ) && dom->acpi_modules[i].length ) + { +DOMPRINTF ("%s: %d bytes at address %" PRIx64"\n" , __FUNCTION__, + dom->acpi_modules[i].length, + dom->acpi_modules[i].guest_addr_out); + + num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
tools/libxc/xc_dom_core.c static int xc_dom_build_ramdisk(struct xc_dom_image *dom) · line 1103
Quoted 10 lines
tools/libxc/xc_dom_core.c +10
-0+XC_PAGE_SHIFT ; + extents =malloc (num_pages *sizeof (*extents)); +if ( !extents ) + { +DOMPRINTF ("%s: Out of memory" , __FUNCTION__); + goto err; + } + + base = dom->acpi_modules[i].guest_addr_out >>XC_PAGE_SHIFT ; +for (j =0 ; j < num_pages; j++)
Here.
Quoted 47 lines
tools/libxc/xc_dom_core.c +34
-0+ extents[j] = base + j; +if (populate_acpi_pages (dom, extents, num_pages) ) + { +DOMPRINTF ("%s: Can populate ACPI pages" , __FUNCTION__); + goto err; + } + + ptr =xc_map_foreign_range (dom->xch, dom->guest_domid, +XC_PAGE_SIZE * num_pages, +PROT_READ |PROT_WRITE , base); +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 · 1 line
1.8.3.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel