Skip to contentSkip to conversation

qemu: generate acpi tables for the guest

PATCH Superseded Michael S. Tsirkin 4 participants 69 messages Jul 24, 2013 – Sep 11, 2013

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v3 cover qemu: generate acpi tables for the guest

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Changes from v2 repost:
- address comment by Anthony - convert to use APIs implemented using QOM
- address comment by Anthony - avoid tricky pointer path, use GArray from glib instead
- Address lots of comments by Hu Tao and Laszlo Ersek
- rebase to latest bits

Changes from v2:
- added missing patches to make it actually build Changes from v1 RFC:
- added code to address cross version compatibility
- rebased to latest bits
- updated seabios code to latest bits (added pvpanic device)

This patchset moves all generation of ACPI tables from guest BIOS to the hypervisor.

Although ACPI tables come from a system BIOS on real hw, it makes sense that the ACPI tables are coupled with the virtual machine, since they have to abstract the x86 machine to the OS's.

This is widely desired as a way to avoid the churn and proliferation of QEMU-specific interfaces associated with ACPI tables in bios code.

There's a bit of code duplication where we already declare similar acpi structures in qemu.

I think it's best to do it in this order: port code directly, and apply cleanups and reduce duplication that results, on top.
This way it's much easier to see that we don't introduce regressions.

In particular, I booted a guest on qemu with and without the change, and verified that ACPI tables are unchanged except for trivial pointer address changes.

Such binary compatibility makes it easier to be confident that this change won't break things.

Michael S. Tsirkin (14):
hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h
i386: add ACPI table files from seabios
acpi: add rules to compile ASL source
acpi: pre-compiled ASL files
loader: use file path size from fw_cfg.h
i386: add bios linker/loader
loader: support for unmapped ROM blobs
loader: allow adding ROMs in done callbacks
i386: define pc guest info
ich9: APIs for pc guest info
piix: APIs for pc guest info
pvpanic: add API to access io port
hpet: add API to find it
i386: ACPI table generation code from seabios

 configure                            |    9 +-
 hw/acpi/ich9.c                       |    6 +
 hw/acpi/piix4.c                      |   29 +-
 hw/core/loader.c                     |   40 +-
 hw/i386/Makefile.objs                |   27 +
 hw/i386/acpi-build.c                 |  907 +++++
 hw/i386/acpi-defs.h                  |  327 ++
 hw/i386/acpi-dsdt-cpu-hotplug.dsl    |   93 +
 hw/i386/acpi-dsdt-dbug.dsl           |   41 +
 hw/i386/acpi-dsdt-hpet.dsl           |   51 +
 hw/i386/acpi-dsdt-isa.dsl            |  117 +
 hw/i386/acpi-dsdt-pci-crs.dsl        |  105 +
 hw/i386/acpi-dsdt.dsl                |  343 ++
 hw/i386/acpi-dsdt.hex.generated      | 4409 ++++++++++++++++++++
 hw/i386/bios-linker-loader.c         |  156 +
 hw/i386/pc.c                         |   37 +-
 hw/i386/pc_piix.c                    |    5 +
 hw/i386/pc_q35.c                     |    3 +
 hw/i386/q35-acpi-dsdt.dsl            |  452 +++
 hw/i386/q35-acpi-dsdt.hex.generated  | 7346 ++++++++++++++++++++++++++++++++++
 hw/i386/ssdt-misc.dsl                |  119 +
 hw/i386/ssdt-misc.hex.generated      |  190 +
 hw/i386/ssdt-pcihp.dsl               |   51 +
 hw/i386/ssdt-pcihp.hex.generated     |  108 +
 hw/i386/ssdt-proc.dsl                |   63 +
 hw/i386/ssdt-proc.hex.generated      |  134 +
 hw/isa/lpc_ich9.c                    |   19 +
 hw/lm32/lm32_hwsetup.h               |    2 +-
 hw/mips/mips_malta.c                 |    2 +-
 hw/misc/pvpanic.c                    |   11 +
 hw/pci-host/piix.c                   |    8 +
 hw/pci-host/q35.c                    |   10 +
 hw/timer/hpet.c                      |    5 +
 include/hw/acpi/ich9.h               |    2 +
 include/hw/i386/acpi-build.h         |    9 +
 include/hw/i386/apic.h               |    2 +
 include/hw/i386/bios-linker-loader.h |   26 +
 include/hw/i386/ich9.h               |    3 +
 include/hw/i386/pc.h                 |   34 +
 include/hw/loader.h                  |    5 +-
 include/hw/nvram/fw_cfg.h            |    4 +-
 include/hw/pci-host/q35.h            |    2 +
 include/hw/timer/hpet.h              |    2 +
 include/qemu/typedefs.h              |    2 +
 scripts/acpi_extract.py              |  362 ++
 scripts/acpi_extract_preprocess.py   |   51 +
 scripts/update-acpi.sh               |    4 +
 vl.c                                 |    3 +
 48 files changed, 15721 insertions(+), 15 deletions(-)
 create mode 100644 hw/i386/acpi-build.c
 create mode 100644 hw/i386/acpi-defs.h
 create mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl
 create mode 100644 hw/i386/acpi-dsdt-dbug.dsl
 create mode 100644 hw/i386/acpi-dsdt-hpet.dsl
 create mode 100644 hw/i386/acpi-dsdt-isa.dsl
 create mode 100644 hw/i386/acpi-dsdt-pci-crs.dsl
 create mode 100644 hw/i386/acpi-dsdt.dsl
 create mode 100644 hw/i386/acpi-dsdt.hex.generated
 create mode 100644 hw/i386/bios-linker-loader.c
 create mode 100644 hw/i386/q35-acpi-dsdt.dsl
 create mode 100644 hw/i386/q35-acpi-dsdt.hex.generated
 create mode 100644 hw/i386/ssdt-misc.dsl
 create mode 100644 hw/i386/ssdt-misc.hex.generated
 create mode 100644 hw/i386/ssdt-pcihp.dsl
 create mode 100644 hw/i386/ssdt-pcihp.hex.generated
 create mode 100644 hw/i386/ssdt-proc.dsl
 create mode 100644 hw/i386/ssdt-proc.hex.generated
 create mode 100644 include/hw/i386/acpi-build.h
 create mode 100644 include/hw/i386/bios-linker-loader.h
 create mode 100755 scripts/acpi_extract.py
 create mode 100755 scripts/acpi_extract_preprocess.py
 create mode 100644 scripts/update-acpi.sh
Signature · 1 line
MST
#1 lore raw

PATCH v3 1/14 hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h

---
 hw/i386/pc.c           | 2 --
 include/hw/i386/apic.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc.c +0 -2
index 2a87563..b0b98a8 100644
@@ -75,8 +75,6 @@
 #define FW_CFG_E820_TABLE (FW_CFG_ARCH_LOCAL + 3)
 #define FW_CFG_HPET (FW_CFG_ARCH_LOCAL + 4)
 
-#define IO_APIC_DEFAULT_ADDRESS 0xfec00000
-
 #define E820_NR_ENTRIES		16
 
 struct e820_entry {
include/hw/i386/apic.h +2 -0
index 1d48e02..edbb37f 100644
@@ -26,6 +26,8 @@ void apic_designate_bsp(DeviceState *d);
 /* pc.c */
 DeviceState *cpu_get_current_apic(void);
 
+#define IO_APIC_DEFAULT_ADDRESS 0xfec00000
+
 /* cpu.c */
 bool cpu_is_bsp(X86CPU *cpu);
 
Signature · 1 line
MST
Reviewed-by on v3 1/14
#3 lore raw

Re: [Qemu-devel] [PATCH v3 01/14] hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h

In reply to Michael S. Tsirkin

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 6 lines
---
 hw/i386/pc.c           | 2 --
 include/hw/i386/apic.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw

PATCH v3 2/14 i386: add ACPI table files from seabios

In reply to Michael S. Tsirkin

This adds ASL code as well as scripts for processing it, imported from seabios git tree
commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd

Will be used for runtime acpi table generation.

Note:
This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.

Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:

src/acpi-dsdt-cpu-hotplug.dsl
src/acpi-dsdt-dbug.dsl
src/acpi-dsdt-hpet.dsl
src/acpi-dsdt-isa.dsl
src/acpi-dsdt-pci-crs.dsl
src/acpi.c
src/acpi.h
src/ssdt-misc.dsl
src/ssdt-pcihp.dsl
src/ssdt-proc.dsl
tools/acpi_extract.py
tools/acpi_extract_preprocess.py

Each one of the listed people agreed to the following:

Quoted 5 lines

If you allow the use of your contribution in QEMU under the terms of GPLv2 or later as proposed by this patch, please respond to this mail including the line:

Acked-by Name <email address>
---
 hw/i386/acpi-dsdt-cpu-hotplug.dsl  |  93 ++++++++
 hw/i386/acpi-dsdt-dbug.dsl         |  41 ++++
 hw/i386/acpi-dsdt-hpet.dsl         |  51 +++++
 hw/i386/acpi-dsdt-isa.dsl          | 117 ++++++++++
 hw/i386/acpi-dsdt-pci-crs.dsl      | 105 +++++++++
 hw/i386/acpi-dsdt.dsl              | 343 ++++++++++++++++++++++++++++
 hw/i386/q35-acpi-dsdt.dsl          | 452 +++++++++++++++++++++++++++++++++++++
 hw/i386/ssdt-misc.dsl              | 119 ++++++++++
 hw/i386/ssdt-pcihp.dsl             |  51 +++++
 hw/i386/ssdt-proc.dsl              |  63 ++++++
 scripts/acpi_extract.py            | 362 +++++++++++++++++++++++++++++
 scripts/acpi_extract_preprocess.py |  51 +++++
 12 files changed, 1848 insertions(+)
 create mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl
 create mode 100644 hw/i386/acpi-dsdt-dbug.dsl
 create mode 100644 hw/i386/acpi-dsdt-hpet.dsl
 create mode 100644 hw/i386/acpi-dsdt-isa.dsl
 create mode 100644 hw/i386/acpi-dsdt-pci-crs.dsl
 create mode 100644 hw/i386/acpi-dsdt.dsl
 create mode 100644 hw/i386/q35-acpi-dsdt.dsl
 create mode 100644 hw/i386/ssdt-misc.dsl
 create mode 100644 hw/i386/ssdt-pcihp.dsl
 create mode 100644 hw/i386/ssdt-proc.dsl
 create mode 100755 scripts/acpi_extract.py
 create mode 100755 scripts/acpi_extract_preprocess.py
hw/i386/acpi-dsdt-cpu-hotplug.dsl new file +93 -0
new file mode 100644
index 0000000..c96ac42
@@ -0,0 +1,93 @@
+/*
+ * 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.
+
+ * 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/>.
+ */
+
+/****************************************************************
+ * CPU hotplug
+ ****************************************************************/
+
+Scope(\_SB) {
+    /* Objects filled in by run-time generated SSDT */
+    External(NTFY, MethodObj)
+    External(CPON, PkgObj)
+
+    /* Methods called by run-time generated SSDT Processor objects */
+    Method(CPMA, 1, NotSerialized) {
+        // _MAT method - create an madt apic buffer
+        // Arg0 = Processor ID = Local APIC ID
+        // Local0 = CPON flag for this cpu
+        Store(DerefOf(Index(CPON, Arg0)), Local0)
+        // Local1 = Buffer (in madt apic form) to return
+        Store(Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}, Local1)
+        // Update the processor id, lapic id, and enable/disable status
+        Store(Arg0, Index(Local1, 2))
+        Store(Arg0, Index(Local1, 3))
+        Store(Local0, Index(Local1, 4))
+        Return (Local1)
+    }
+    Method(CPST, 1, NotSerialized) {
+        // _STA method - return ON status of cpu
+        // Arg0 = Processor ID = Local APIC ID
+        // Local0 = CPON flag for this cpu
+        Store(DerefOf(Index(CPON, Arg0)), Local0)
+        If (Local0) {
+            Return (0xF)
+        } Else {
+            Return (0x0)
+        }
+    }
+    Method(CPEJ, 2, NotSerialized) {
+        // _EJ0 method - eject callback
+        Sleep(200)
+    }
+
+    /* CPU hotplug notify method */
+    OperationRegion(PRST, SystemIO, 0xaf00, 32)
+    Field(PRST, ByteAcc, NoLock, Preserve) {
+        PRS, 256
+    }
+    Method(PRSC, 0) {
+        // Local5 = active cpu bitmap
+        Store(PRS, Local5)
+        // Local2 = last read byte from bitmap
+        Store(Zero, Local2)
+        // Local0 = Processor ID / APIC ID iterator
+        Store(Zero, Local0)
+        While (LLess(Local0, SizeOf(CPON))) {
+            // Local1 = CPON flag for this cpu
+            Store(DerefOf(Index(CPON, Local0)), Local1)
+            If (And(Local0, 0x07)) {
+                // Shift down previously read bitmap byte
+                ShiftRight(Local2, 1, Local2)
+            } Else {
+                // Read next byte from cpu bitmap
+                Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2)
+            }
+            // Local3 = active state for this cpu
+            Store(And(Local2, 1), Local3)
+
+            If (LNotEqual(Local1, Local3)) {
+                // State change - update CPON with new state
+                Store(Local3, Index(CPON, Local0))
+                // Do CPU notify
+                If (LEqual(Local3, 1)) {
+                    NTFY(Local0, 1)
+                } Else {
+                    NTFY(Local0, 3)
+                }
+            }
+            Increment(Local0)
+        }
+    }
+}
hw/i386/acpi-dsdt-dbug.dsl new file +41 -0

41 lines not on this page · raw message

hw/i386/acpi-dsdt-hpet.dsl new file +51 -0

51 lines not on this page · raw message

hw/i386/acpi-dsdt-isa.dsl new file +117 -0

117 lines not on this page · raw message

hw/i386/acpi-dsdt-pci-crs.dsl new file +105 -0

105 lines not on this page · raw message

hw/i386/acpi-dsdt.dsl new file +343 -0

343 lines not on this page · raw message

hw/i386/q35-acpi-dsdt.dsl new file +452 -0

452 lines not on this page · raw message

hw/i386/ssdt-misc.dsl new file +119 -0

119 lines not on this page · raw message

hw/i386/ssdt-pcihp.dsl new file +51 -0

51 lines not on this page · raw message

hw/i386/ssdt-proc.dsl new file +63 -0

63 lines not on this page · raw message

scripts/acpi_extract.py new file +362 -0

362 lines not on this page · raw message

scripts/acpi_extract_preprocess.py new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
MST
#5 lore raw

PATCH v3 3/14 acpi: add rules to compile ASL source

In reply to Michael S. Tsirkin

Detect presence of IASL compiler and use it to process ASL source. If not there, use pre-compiled files in-tree. Add script to update the in-tree files.

Note: distros are known to silently update iasl
so detect correct iasl flags for the installed version on each run as opposed to at configure time.

---
 configure              |  9 ++++++++-
 hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
 scripts/update-acpi.sh |  4 ++++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 scripts/update-acpi.sh
configure +8 -1
index 877a821..9f3236f 100755
@@ -119,6 +119,7 @@ path_of() {
 # default parameters
 source_path=`dirname "$0"`
 cpu=""
+iasl="iasl"
 interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
 cross_prefix=""
@@ -253,6 +254,8 @@ for opt do
   ;;
   --cc=*) CC="$optarg"
   ;;
+  --iasl=*) iasl="$optarg"
+  ;;
   --source-path=*) source_path="$optarg"
   ;;
   --cpu=*) cpu="$optarg"
@@ -1026,6 +1029,7 @@ echo "Advanced options (experts only):"
 echo "  --source-path=PATH       path of source code [$source_path]"
 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC                  use C compiler CC [$cc]"
+echo "  --iasl=IASL              use ACPI compiler IASL [$iasl]"
 echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
 echo "                           build time"
 echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
@@ -4110,6 +4114,9 @@ else
 fi
 echo "PYTHON=$python" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
+if $iasl -h > /dev/null 2>&1; then
+  echo "IASL=$iasl" >> $config_host_mak
+fi
 echo "CC_I386=$cc_i386" >> $config_host_mak
 echo "HOST_CC=$host_cc" >> $config_host_mak
 echo "OBJCC=$objcc" >> $config_host_mak
@@ -4570,7 +4577,7 @@ for rom in seabios vgabios ; do
     echo "BCC=bcc" >> $config_mak
     echo "CPP=$cpp" >> $config_mak
     echo "OBJCOPY=objcopy" >> $config_mak
-    echo "IASL=iasl" >> $config_mak
+    echo "IASL=$iasl" >> $config_mak
     echo "LD=$ld" >> $config_mak
 done
 
hw/i386/Makefile.objs +22 -0
index 205d22e..013d250 100644
@@ -4,3 +4,25 @@ obj-y += pc.o pc_piix.o pc_q35.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 obj-y += kvmvapic.o
+
+iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
+    ; then echo "$(2)"; else echo "$(3)"; fi ;)
+
+ifdef IASL
+#IASL Present. Generate hex files from .dsl
+hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
+	$(call quiet-command, cpp -P $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
+	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
+	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
+	$(call quiet-command, $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
+	$(call quiet-command, cat $*.off > $@, "  CAT $(TARGET_DIR)$@")
+else
+#IASL Not present. Restore pre-generated hex files.
+hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated
+	$(call quiet-command, cp -f $< $@, "  CP $(TARGET_DIR)$@")
+endif
+
+.PHONY: cleanhex
+cleanhex:
+	rm -f hw/i386/*hex
+clean: cleanhex
scripts/update-acpi.sh new file +4 -0
new file mode 100644
index 0000000..b5f05ff
@@ -0,0 +1,4 @@
+cd x86_64-softmmu
+for file in hw/i386/*.hex; do
+    cp -f $file ../$file.generated
+done
Signature · 1 line
MST
Reviewed-by on v3 3/14
#6 lore raw

Re: [Qemu-devel] [PATCH v3 03/14] acpi: add rules to compile ASL source

Quoted 7 lines · Michael S. Tsirkin

Detect presence of IASL compiler and use it to process ASL source. If not there, use pre-compiled files in-tree. Add script to update the in-tree files.

Note: distros are known to silently update iasl
so detect correct iasl flags for the installed version on each run as opposed to at configure time.

cheers,
Gerd

#7 lore raw

PATCH v3 4/14 acpi: pre-compiled ASL files

In reply to Michael S. Tsirkin

Add pre-compiled ASL files. Useful for systems that do not have IASL.

---
 hw/i386/acpi-dsdt.hex.generated     | 4409 +++++++++++++++++++++
 hw/i386/q35-acpi-dsdt.hex.generated | 7346 +++++++++++++++++++++++++++++++++++
 hw/i386/ssdt-misc.hex.generated     |  190 +
 hw/i386/ssdt-pcihp.hex.generated    |  108 +
 hw/i386/ssdt-proc.hex.generated     |  134 +
 5 files changed, 12187 insertions(+)
 create mode 100644 hw/i386/acpi-dsdt.hex.generated
 create mode 100644 hw/i386/q35-acpi-dsdt.hex.generated
 create mode 100644 hw/i386/ssdt-misc.hex.generated
 create mode 100644 hw/i386/ssdt-pcihp.hex.generated
 create mode 100644 hw/i386/ssdt-proc.hex.generated
hw/i386/acpi-dsdt.hex.generated new file +4409 -0
new file mode 100644
index 0000000..68cab3e
@@ -0,0 +1,4409 @@
+static unsigned char AcpiDsdtAmlCode[] = {
+0x44,
+0x53,
+0x44,
+0x54,
+0x37,
+0x11,
+0x0,
+0x0,
+0x1,
+0xe1,
+0x42,
+0x58,
+0x50,
+0x43,
+0x0,
+0x0,
+0x42,
+0x58,
+0x44,
+0x53,
+0x44,
+0x54,
+0x0,
+0x0,
+0x1,
+0x0,
+0x0,
+0x0,
+0x49,
+0x4e,
+0x54,
+0x4c,
+0x28,
+0x5,
+0x10,
+0x20,
+0x10,
+0x49,
+0x4,
+0x5c,
+0x0,
+0x5b,
+0x80,
+0x44,
+0x42,
+0x47,
+0x5f,
+0x1,
+0xb,
+0x2,
+0x4,
+0x1,
+0x5b,
+0x81,
+0xb,
+0x44,
+0x42,
+0x47,
+0x5f,
+0x1,
+0x44,
+0x42,
+0x47,
+0x42,
+0x8,
+0x14,
+0x2c,
+0x44,
+0x42,
+0x55,
+0x47,
+0x1,
+0x98,
+0x68,
+0x60,
+0x96,
+0x60,
+0x60,
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+0x93,
+0x50,
+0x31,
+0x56,
+0x5f,
+0x0,
+0xa4,
+0x43,
+0x52,
+0x45,
+0x53,
+0x8f,
+0x43,
+0x52,
+0x36,
+0x34,
+0xa,
+0xe,
+0x50,
+0x53,
+0x36,
+0x34,
+0x8f,
+0x43,
+0x52,
+0x36,
+0x34,
+0xa,
+0x16,
+0x50,
+0x45,
+0x36,
+0x34,
+0x8f,
+0x43,
+0x52,
+0x36,
+0x34,
+0xa,
+0x26,
+0x50,
+0x4c,
+0x36,
+0x34,
+0x70,
+0x50,
+0x31,
+0x53,
+0x5f,
+0x50,
+0x53,
+0x36,
+0x34,
+0x70,
+0x50,
+0x31,
+0x45,
+0x5f,
+0x50,
+0x45,
+0x36,
+0x34,
+0x70,
+0x50,
+0x31,
+0x4c,
+0x5f,
+0x50,
+0x4c,
+0x36,
+0x34,
+0x84,
+0x43,
+0x52,
+0x45,
+0x53,
+0x43,
+0x52,
+0x36,
+0x34,
+0x60,
+0xa4,
+0x60,
+0x10,
+0x4d,
+0x8,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x5b,
+0x82,
+0x45,
+0x8,
+0x48,
+0x50,
+0x45,
+0x54,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xc,
+0x41,
+0xd0,
+0x1,
+0x3,
+0x8,
+0x5f,
+0x55,
+0x49,
+0x44,
+0x0,
+0x5b,
+0x80,
+0x48,
+0x50,
+0x54,
+0x4d,
+0x0,
+0xc,
+0x0,
+0x0,
+0xd0,
+0xfe,
+0xb,
+0x0,
+0x4,
+0x5b,
+0x81,
+0x10,
+0x48,
+0x50,
+0x54,
+0x4d,
+0x13,
+0x56,
+0x45,
+0x4e,
+0x44,
+0x20,
+0x50,
+0x52,
+0x44,
+0x5f,
+0x20,
+0x14,
+0x36,
+0x5f,
+0x53,
+0x54,
+0x41,
+0x0,
+0x70,
+0x56,
+0x45,
+0x4e,
+0x44,
+0x60,
+0x70,
+0x50,
+0x52,
+0x44,
+0x5f,
+0x61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
+0x4c,
+0x4e,
+0x4b,
+0x42,
+0x0,
+0x12,
+0xe,
+0x4,
+0xc,
+0xff,
+0xff,
+0x18,
+0x0,
+0xa,
+0x3,
+0x4c,
+0x4e,
+0x4b,
+0x43,
+0x0,
+0x12,
+0xd,
+0x4,
+0xc,
+0xff,
+0xff,
+0x19,
+0x0,
+0x0,
+0x4c,
+0x4e,
+0x4b,
+0x41,
+0x0,
+0x12,
+0xd,
+0x4,
+0xc,
+0xff,
+0xff,
+0x19,
+0x0,
+0x1,
+0x4c,
+0x4e,
+0x4b,
+0x42,
+0x0,
+0x12,
+0xe,
+0x4,
+0xc,
+0xff,
+0xff,
+0x19,
+0x0,
+0xa,
+0x2,
+0x4c,
+0x4e,
+0x4b,
+0x43,
+0x0,
+0x12,
+0xe,
+0x4,
+0xc,
+0xff,
+0xff,
+0x19,
+0x0,
+0xa,
+0x3,
+0x4c,
+0x4e,
+0x4b,
+0x44,
+0x0,
+0x12,
+0xd,
+0x4,
+0xc,
+0xff,
+0xff,
+0x1a,
+0x0,
+0x0,
+0x4c,
+0x4e,
+0x4b,
+0x42,
+0x0,
+0x12,
+0xd,
+0x4,
+0xc,
+0xff,
+0xff,
+0x1a,
+0x0,
+0x1,
+0x4c,
+0x4e,
+0x4b,
+0x43,
+0x0,
+0x12,
+0xe,
+0x4,
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

hw/i386/q35-acpi-dsdt.hex.generated new file +7346 -0

7,346 lines not on this page · raw message

hw/i386/ssdt-misc.hex.generated new file +190 -0

190 lines not on this page · raw message

hw/i386/ssdt-pcihp.hex.generated new file +108 -0

108 lines not on this page · raw message

hw/i386/ssdt-proc.hex.generated new file +134 -0

134 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
MST

Part of the diff is not shown here. View the raw message.

#8 lore raw

PATCH v3 5/14 loader: use file path size from fw_cfg.h

In reply to Michael S. Tsirkin

Avoid a bit of code duplication, make
max file path constant reusable.

---
 hw/core/loader.c          | 2 +-
 include/hw/nvram/fw_cfg.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
hw/core/loader.c +1 -1
index c3c28cf..c4dd665 100644
@@ -645,7 +645,7 @@ int rom_add_file(const char *file, const char *fw_dir,
     rom_insert(rom);
     if (rom->fw_file && fw_cfg) {
         const char *basename;
-        char fw_file_name[56];
+        char fw_file_name[FW_CFG_MAX_FILE_PATH];
 
         basename = strrchr(rom->fw_file, '/');
         if (basename) {
include/hw/nvram/fw_cfg.h +3 -1
index f60dd67..fa5c8c6 100644
@@ -46,12 +46,14 @@
 
 #define FW_CFG_INVALID          0xffff
 
+#define FW_CFG_MAX_FILE_PATH    56
+
 #ifndef NO_QEMU_PROTOS
 typedef struct FWCfgFile {
     uint32_t  size;        /* file size */
     uint16_t  select;      /* write this to 0x510 to read it */
     uint16_t  reserved;
-    char      name[56];
+    char      name[FW_CFG_MAX_FILE_PATH];
 } FWCfgFile;
 
 typedef struct FWCfgFiles {
Signature · 1 line
MST
Reviewed-by on v3 5/14
#9 lore raw

Re: [Qemu-devel] [PATCH v3 05/14] loader: use file path size from fw_cfg.h

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 5 lines

Avoid a bit of code duplication, make
max file path constant reusable.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#11 lore raw

PATCH v3 6/14 i386: add bios linker/loader

In reply to Michael S. Tsirkin

This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linking

---
 hw/i386/Makefile.objs                |   1 +
 hw/i386/bios-linker-loader.c         | 156 +++++++++++++++++++++++++++++++++++
 include/hw/i386/bios-linker-loader.h |  26 ++++++
 3 files changed, 183 insertions(+)
 create mode 100644 hw/i386/bios-linker-loader.c
 create mode 100644 include/hw/i386/bios-linker-loader.h
hw/i386/Makefile.objs +1 -0
index 013d250..71be2da 100644
@@ -4,6 +4,7 @@ obj-y += pc.o pc_piix.o pc_q35.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 obj-y += kvmvapic.o
+obj-y += bios-linker-loader.o
 
 iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
     ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/bios-linker-loader.c new file +156 -0

156 lines not on this page · raw message

include/hw/i386/bios-linker-loader.h new file +26 -0
new file mode 100644
index 0000000..18c3868
@@ -0,0 +1,26 @@
+#ifndef BIOS_LINKER_LOADER_H
+#define BIOS_LINKER_LOADER_H
+
+#include <glib.h>
+#include <stdbool.h>
+#include <inttypes.h>
+
+GArray *bios_linker_init(void);
+
+void bios_linker_alloc(GArray *linker,
+                       const char *file,
+                       uint32_t alloc_align,
+                       bool alloc_fseg);
+
+void bios_linker_add_checksum(GArray *linker, const char *file, void *table,
+                              void *start, unsigned size, uint8_t *checksum);
+
+
+void bios_linker_add_pointer(GArray *linker,
+                             const char *dest_file,
+                             const char *src_file,
+                             GArray *table, void *pointer,
+                             uint8_t pointer_size);
+
+void *bios_linker_cleanup(GArray *linker);
+#endif
Signature · 1 line
MST
Reviewed-by on v3 6/14
#12 lore raw

Re: [Qemu-devel] [PATCH v3 06/14] i386: add bios linker/loader

Quoted 6 lines · Michael S. Tsirkin

This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linking

cheers,
Gerd

#13 lore raw

Re: [Qemu-devel] [PATCH v3 06/14] i386: add bios linker/loader

In reply to Michael S. Tsirkin

Hi,

Hacked up coreboot support to verify the interface.

hw/i386/bios-linker-loader.c line 40

Quoted 8 lines
hw/i386/bios-linker-loader.c new file +8 -0
+        /*
+         * COMMAND_ALLOCATE - allocate a table from @alloc_file
+         * subject to @alloc_align alignment (must be power of 2)
+         * and @alloc_zone (can be HIGH or FSEG) requirements.
+         *
+         * Must appear exactly once for each file, and before
+         * this file is referenced by any other command.
+         */

Do we need alloc_zone?

Rules are simple: rsdp goes to fseg, everything else to high, correct?

Both seabios and coreboot handle that by first placing *all* acpi tables in high memory, then go place a rsdp copy in fseg.

hw/i386/bios-linker-loader.c line 52

Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6 -0
+        /*
+         * COMMAND_ADD_POINTER - patch the table (originating from
+         * @dest_file) at @pointer_offset, by adding a pointer to the table
+         * originating from @src_file. 1,2,4 or 8 byte unsigned
+         * addition is used depending on @pointer_size.
+         */

Do we need pointer_size?

Current tables use 4 bytes only.

1+2 bytes is pointless, the src_file address will be big enougth that it doesn't fit into one or two bytes, so I doubt they will ever be used.

8 bytes would only be used when placing acpi tables above 4g. Is that something expected to happen? If not 4 bytes is enough, even for 8 byte pointers as the 4 high bytes would be zero no matter what.

cheers,
Gerd

#14 lore raw

Re: [Qemu-devel] [PATCH v3 06/14] i386: add bios linker/loader

Quoted 13 lines · Gerd Hoffmann

Hi,

Hacked up coreboot support to verify the interface.

hw/i386/bios-linker-loader.c line 40

Quoted 8 lines
hw/i386/bios-linker-loader.c new file +8 -0
+        /*
+         * COMMAND_ALLOCATE - allocate a table from @alloc_file
+         * subject to @alloc_align alignment (must be power of 2)
+         * and @alloc_zone (can be HIGH or FSEG) requirements.
+         *
+         * Must appear exactly once for each file, and before
+         * this file is referenced by any other command.
+         */
Quoted 3 lines

Do we need alloc_zone?

Rules are simple: rsdp goes to fseg, everything else to high, correct?

Yes but I prefer marking it explicitly at link time and avoid hard-coding things in the bios, so that whoever allocates memory can go just by linker rules and not poke at tables themselves.

Quoted 2 lines

Both seabios and coreboot handle that by first placing *all* acpi tables in high memory, then go place a rsdp copy in fseg.

No, what happens is we put everything in tmp memory, then copy where appropriately.

Quoted 9 lines

hw/i386/bios-linker-loader.c line 52

Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6 -0
+        /*
+         * COMMAND_ADD_POINTER - patch the table (originating from
+         * @dest_file) at @pointer_offset, by adding a pointer to the table
+         * originating from @src_file. 1,2,4 or 8 byte unsigned
+         * addition is used depending on @pointer_size.
+         */

Do we need pointer_size?

Quoted 7 lines

Current tables use 4 bytes only.

1+2 bytes is pointless, the src_file address will be big enougth that it doesn't fit into one or two bytes, so I doubt they will ever be used.

8 bytes would only be used when placing acpi tables above 4g. Is that something expected to happen?

Yes, the spec allows 64 bit pointers.

Quoted 5 lines

If not 4 bytes is enough, even for 8 byte pointers as the 4 high bytes would be zero no matter what.

cheers,
Gerd

#15 lore raw

PATCH v3 7/14 loader: support for unmapped ROM blobs

In reply to Michael S. Tsirkin

Support ROM blobs not mapped into guest memory:
let user pass in MR for memory serving as the backing store.

---
 hw/core/loader.c       | 32 +++++++++++++++++++++++++++++---
 hw/lm32/lm32_hwsetup.h |  2 +-
 include/hw/loader.h    |  4 ++--
 3 files changed, 32 insertions(+), 6 deletions(-)
hw/core/loader.c +29 -3
index c4dd665..c2309e6 100644
@@ -576,6 +576,7 @@ struct Rom {
     size_t datasize;
 
     uint8_t *data;
+    MemoryRegion *mr;
     int isrom;
     char *fw_dir;
     char *fw_file;
@@ -675,7 +676,7 @@ err:
 }
 
 int rom_add_blob(const char *name, const void *blob, size_t len,
-                 hwaddr addr)
+                 hwaddr addr, MemoryRegion *mr)
 {
     Rom *rom;
 
@@ -685,6 +686,11 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
     rom->romsize  = len;
     rom->datasize = len;
     rom->data     = g_malloc0(rom->datasize);
+    rom->mr       = mr;
+    if (mr) {
+        assert(memory_region_is_ram(mr));
+        rom->isrom = memory_region_is_rom(mr);
+    }
     memcpy(rom->data, blob, len);
     rom_insert(rom);
     return 0;
@@ -725,13 +731,21 @@ static void rom_reset(void *unused)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
+        if (rom->mr) {
+            continue;
+        }
         if (rom->fw_file) {
             continue;
         }
         if (rom->data == NULL) {
             continue;
         }
-        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        if (rom->mr) {
+            void *host = memory_region_get_ram_ptr(rom->mr);
+            memcpy(host, rom->data, rom->datasize);
+        } else {
+            cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        }
         if (rom->isrom) {
             /* rom needs to be written only once */
             g_free(rom->data);
@@ -781,6 +795,9 @@ static Rom *find_rom(hwaddr addr)
         if (rom->fw_file) {
             continue;
         }
+        if (rom->mr) {
+            continue;
+        }
         if (rom->addr > addr) {
             continue;
         }
@@ -808,6 +825,9 @@ int rom_copy(uint8_t *dest, hwaddr addr, size_t size)
         if (rom->fw_file) {
             continue;
         }
+        if (rom->mr) {
+            continue;
+        }
         if (rom->addr + rom->romsize < addr) {
             continue;
         }
@@ -867,7 +887,13 @@ void do_info_roms(Monitor *mon, const QDict *qdict)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (!rom->fw_file) {
+        if (rom->mr) {
+            monitor_printf(mon, "%s"
+                           " size=0x%06zx name=\"%s\"\n",
+                           rom->mr->name,
+                           rom->romsize,
+                           rom->name);
+        } else if (!rom->fw_file) {
             monitor_printf(mon, "addr=" TARGET_FMT_plx
                            " size=0x%06zx mem=%s name=\"%s\"\n",
                            rom->addr, rom->romsize,
hw/lm32/lm32_hwsetup.h +1 -1
index 3449bd8..d6914d6 100644
@@ -73,7 +73,7 @@ static inline void hwsetup_free(HWSetup *hw)
 static inline void hwsetup_create_rom(HWSetup *hw,
         hwaddr base)
 {
-    rom_add_blob("hwsetup", hw->data, TARGET_PAGE_SIZE, base);
+    rom_add_blob("hwsetup", hw->data, TARGET_PAGE_SIZE, base, NULL);
 }
 
 static inline void hwsetup_add_u8(HWSetup *hw, uint8_t u)
include/hw/loader.h +2 -2
index eb9c9a3..cdb7b4b 100644
@@ -40,7 +40,7 @@ void pstrcpy_targphys(const char *name,
 int rom_add_file(const char *file, const char *fw_dir,
                  hwaddr addr, int32_t bootindex);
 int rom_add_blob(const char *name, const void *blob, size_t len,
-                 hwaddr addr);
+                 hwaddr addr, MemoryRegion *mr);
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
                         size_t romsize, hwaddr addr);
 int rom_load_all(void);
@@ -52,7 +52,7 @@ void do_info_roms(Monitor *mon, const QDict *qdict);
 #define rom_add_file_fixed(_f, _a, _i)          \
     rom_add_file(_f, NULL, _a, _i)
 #define rom_add_blob_fixed(_f, _b, _l, _a)      \
-    rom_add_blob(_f, _b, _l, _a)
+    rom_add_blob(_f, _b, _l, _a, NULL)
 
 #define PC_ROM_MIN_VGA     0xc0000
 #define PC_ROM_MIN_OPTION  0xc8000
Signature · 1 line
MST
#16 lore raw

Re: [Qemu-devel] [PATCH v3 07/14] loader: support for unmapped ROM blobs

Quoted 4 lines · Michael S. Tsirkin
     QTAILQ_FOREACH(rom, &roms, next) {
hw/core/loader.c +3 -0
+        if (rom->mr) {
+            continue;
+        }

hw/core/loader.c static void rom_reset(void *unused) · line 745

Quoted 10 lines
hw/core/loader.c +3 -1
         if (rom->fw_file) {
             continue;
         }
         if (rom->data == NULL) {
             continue;
         }
-        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        if (rom->mr) {
+            void *host = memory_region_get_ram_ptr(rom->mr);
+            memcpy(host, rom->data, rom->datasize);

I think this code never ever runs ...

cheers,
Gerd

#17 lore raw

Re: [Qemu-devel] [PATCH v3 07/14] loader: support for unmapped ROM blobs

Quoted 16 lines · Gerd Hoffmann
Quoted 4 lines · Michael S. Tsirkin
     QTAILQ_FOREACH(rom, &roms, next) {
hw/core/loader.c +3 -0
+        if (rom->mr) {
+            continue;
+        }

hw/core/loader.c static void rom_reset(void *unused) · line 745

Quoted 10 lines
hw/core/loader.c +3 -1
         if (rom->fw_file) {
             continue;
         }
         if (rom->data == NULL) {
             continue;
         }
-        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        if (rom->mr) {
+            void *host = memory_region_get_ram_ptr(rom->mr);
+            memcpy(host, rom->data, rom->datasize);
Quoted 5 lines

I think this code never ever runs ...

cheers,
Gerd

Could you be clearer please? This chunk is in rom_reset, I think it runs on reset.

#18 lore raw

Re: [Qemu-devel] [PATCH v3 07/14] loader: support for unmapped ROM blobs

Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Gerd Hoffmann
Quoted 4 lines · Michael S. Tsirkin
     QTAILQ_FOREACH(rom, &roms, next) {
hw/core/loader.c +3 -0
+        if (rom->mr) {
+            continue;
+        }

hw/core/loader.c static void rom_reset(void *unused) · line 745

Quoted 10 lines
hw/core/loader.c +3 -1
         if (rom->fw_file) {
             continue;
         }
         if (rom->data == NULL) {
             continue;
         }
-        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        if (rom->mr) {
+            void *host = memory_region_get_ram_ptr(rom->mr);
+            memcpy(host, rom->data, rom->datasize);

I think this code never ever runs ...

Quoted 7 lines
Quoted 3 lines

cheers,
Gerd

Could you be clearer please? This chunk is in rom_reset, I think it runs on reset.

You have the "if (rom->mr)" twice in the loop. The first does continue so the second will never ever evaluate to true, thereby making the memcpy dead code.

cheers,
Gerd

#19 lore raw

Re: [Qemu-devel] [PATCH v3 07/14] loader: support for unmapped ROM blobs

Quoted 28 lines · Gerd Hoffmann
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Gerd Hoffmann
Quoted 4 lines · Michael S. Tsirkin
     QTAILQ_FOREACH(rom, &roms, next) {
hw/core/loader.c +3 -0
+        if (rom->mr) {
+            continue;
+        }

hw/core/loader.c static void rom_reset(void *unused) · line 745

Quoted 10 lines
hw/core/loader.c +3 -1
         if (rom->fw_file) {
             continue;
         }
         if (rom->data == NULL) {
             continue;
         }
-        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        if (rom->mr) {
+            void *host = memory_region_get_ram_ptr(rom->mr);
+            memcpy(host, rom->data, rom->datasize);

I think this code never ever runs ...

Quoted 7 lines
Quoted 3 lines

cheers,
Gerd

Could you be clearer please? This chunk is in rom_reset, I think it runs on reset.

Quoted 6 lines

You have the "if (rom->mr)" twice in the loop. The first does continue so the second will never ever evaluate to true, thereby making the memcpy dead code.

cheers,
Gerd

Hmm that's a bugt I think. Thanks!

#20 lore raw

Re: [Qemu-devel] [PATCH v3 07/14] loader: support for unmapped ROM blobs

In reply to Gerd Hoffmann
Quoted 28 lines · Gerd Hoffmann
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Gerd Hoffmann
Quoted 4 lines · Michael S. Tsirkin
     QTAILQ_FOREACH(rom, &roms, next) {
hw/core/loader.c +3 -0
+        if (rom->mr) {
+            continue;
+        }

hw/core/loader.c static void rom_reset(void *unused) · line 745

Quoted 10 lines
hw/core/loader.c +3 -1
         if (rom->fw_file) {
             continue;
         }
         if (rom->data == NULL) {
             continue;
         }
-        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+        if (rom->mr) {
+            void *host = memory_region_get_ram_ptr(rom->mr);
+            memcpy(host, rom->data, rom->datasize);

I think this code never ever runs ...

Quoted 7 lines
Quoted 3 lines

cheers,
Gerd

Could you be clearer please? This chunk is in rom_reset, I think it runs on reset.

Quoted 7 lines

You have the "if (rom->mr)" twice in the loop. The first does continue so the second will never ever evaluate to true, thereby making the memcpy dead code.

cheers,
Gerd

Ow, good catch. I'll fix that up, thanks!

#21 lore raw

PATCH v3 8/14 loader: allow adding ROMs in done callbacks

In reply to Michael S. Tsirkin

Don't abort if machine done callbacks add ROMs.

---
 hw/core/loader.c    | 6 +++++-
 include/hw/loader.h | 1 +
 vl.c                | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)
hw/core/loader.c +5 -1
index c2309e6..c68f757 100644
@@ -778,10 +778,14 @@ int rom_load_all(void)
         memory_region_unref(section.mr);
     }
     qemu_register_reset(rom_reset, NULL);
-    roms_loaded = 1;
     return 0;
 }
 
+void rom_load_done(void)
+{
+    roms_loaded = 1;
+}
+
 void rom_set_fw(FWCfgState *f)
 {
     fw_cfg = f;
include/hw/loader.h +1 -0
index cdb7b4b..8f0d142 100644
@@ -44,6 +44,7 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
                         size_t romsize, hwaddr addr);
 int rom_load_all(void);
+void rom_load_done(void);
 void rom_set_fw(FWCfgState *f);
 int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
 void *rom_ptr(hwaddr addr);
vl.c +3 -0
index 25b8f2f..3d56ec0 100644
@@ -4408,6 +4408,9 @@ int main(int argc, char **argv, char **envp)
     qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
     qemu_run_machine_init_done_notifiers();
 
+    /* Done notifiers can load ROMs */
+    rom_load_done();
+
     qemu_system_reset(VMRESET_SILENT);
     if (loadvm) {
         if (load_vmstate(loadvm) < 0) {
Signature · 1 line
MST
Reviewed-by on v3 8/14
#22 lore raw

Re: [Qemu-devel] [PATCH v3 08/14] loader: allow adding ROMs in done callbacks

Quoted 1 line · Michael S. Tsirkin

Don't abort if machine done callbacks add ROMs.

cheers,
Gerd

#23 lore raw

PATCH v3 9/14 i386: define pc guest info

In reply to Michael S. Tsirkin

This defines a structure that will be used to fill in guest info table. This structure will be filled in in follow-up patches, using QOM. Fill in NUMA node info is not available in QOM so it is filled in directly.

---
 hw/i386/pc.c            | 33 +++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h    | 31 +++++++++++++++++++++++++++++++
 include/qemu/typedefs.h |  1 +
 3 files changed, 65 insertions(+)
hw/i386/pc.c +33 -0
index b0b98a8..b9b8f92 100644
@@ -1017,6 +1017,27 @@ static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info)
     fw_cfg_add_file(guest_info->fw_cfg, "etc/pci-info", info, sizeof *info);
 }
 
+static void pc_set_cpu_guest_info(CPUState *cpu, void *arg)
+{
+    PcGuestInfo *guest_info = arg;
+    CPUClass *klass = CPU_GET_CLASS(cpu);
+    uint64_t apic_id = klass->get_arch_id(cpu);
+    int j;
+
+    assert(apic_id <= MAX_CPUMASK_BITS);
+    assert(apic_id < guest_info->apic_id_limit);
+
+    set_bit(apic_id, guest_info->found_cpus);
+
+    for (j = 0; j < guest_info->numa_nodes; j++) {
+        assert(cpu->cpu_index < max_cpus);
+        if (test_bit(cpu->cpu_index, node_cpumask[j])) {
+            guest_info->node_cpu[apic_id] = cpu_to_le64(j);
+            break;
+        }
+    }
+}
+
 typedef struct PcGuestInfoState {
     PcGuestInfo info;
     Notifier machine_done;
@@ -1037,6 +1058,18 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
     PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
     PcGuestInfo *guest_info = &guest_info_state->info;
 
+    guest_info->ram_size = below_4g_mem_size + above_4g_mem_size;
+    guest_info->apic_id_limit = pc_apic_id_limit(max_cpus);
+    guest_info->apic_xrupt_override = kvm_allows_irq0_override();
+    guest_info->numa_nodes = nb_numa_nodes;
+    guest_info->node_mem = g_memdup(node_mem, guest_info->numa_nodes *
+                                    sizeof *guest_info->node_mem);
+    guest_info->node_cpu = g_malloc0(guest_info->apic_id_limit *
+                                     sizeof *guest_info->node_cpu);
+
+    memset(&guest_info->found_cpus, 0, sizeof guest_info->found_cpus);
+    qemu_for_each_cpu(pc_set_cpu_guest_info, guest_info);
+
     guest_info->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
     if (sizeof(hwaddr) == 4) {
         guest_info->pci_info.w64.begin = 0;
include/hw/i386/pc.h +31 -0
index 7fb97b0..7c0bd50 100644
@@ -9,6 +9,9 @@
 #include "hw/i386/ioapic.h"
 
 #include "qemu/range.h"
+#include "qemu/bitmap.h"
+#include "sysemu/sysemu.h"
+#include "hw/pci/pci.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -17,9 +20,37 @@ typedef struct PcPciInfo {
     Range w64;
 } PcPciInfo;
 
+/* Matches the value hard-coded in BIOS */
+#define PC_GUEST_PORT_ACPI_PM_BASE      0xb000
+
+struct AcpiPmInfo {
+    bool s3_disabled;
+    bool s4_disabled;
+    uint8_t s4_val;
+    uint16_t sci_int;
+    uint8_t acpi_enable_cmd;
+    uint8_t acpi_disable_cmd;
+    uint32_t gpe0_blk;
+    uint32_t gpe0_blk_len;
+};
+
 struct PcGuestInfo {
     PcPciInfo pci_info;
     bool has_pci_info;
+    hwaddr ram_size;
+    unsigned apic_id_limit;
+    bool apic_xrupt_override;
+    bool has_hpet;
+    uint64_t numa_nodes;
+    uint64_t *node_mem;
+    uint64_t *node_cpu;
+    DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1);
+    DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
+    AcpiPmInfo pm;
+    uint64_t mcfg_base;
+    const unsigned char *dsdt_code;
+    unsigned dsdt_size;
+    uint16_t pvpanic_port;
     FWCfgState *fw_cfg;
 };
 
include/qemu/typedefs.h +1 -0
index ac9f8d4..cb66e19 100644
@@ -65,5 +65,6 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 1 line
MST
Reviewed-by on v3 9/14
#24 lore raw

Re: [Qemu-devel] [PATCH v3 09/14] i386: define pc guest info

Quoted 3 lines · Michael S. Tsirkin

This defines a structure that will be used to fill in guest info table. This structure will be filled in in follow-up patches, using QOM. Fill in NUMA node info is not available in QOM so it is filled in directly.

cheers,
Gerd

#25 lore raw

Re: [Qemu-devel] [PATCH v3 09/14] i386: define pc guest info

In reply to Michael S. Tsirkin

Am 24.07.2013 18:02, schrieb Michael S. Tsirkin:

Quoted 17 lines

This defines a structure that will be used to fill in guest info table. This structure will be filled in in follow-up patches, using QOM. Fill in NUMA node info is not available in QOM so it is filled in directly.

---
 hw/i386/pc.c            | 33 +++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h    | 31 +++++++++++++++++++++++++++++++
 include/qemu/typedefs.h |  1 +
 3 files changed, 65 insertions(+)
hw/i386/pc.c +0 -0
index b0b98a8..b9b8f92 100644

hw/i386/pc.c static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info) · line 1024

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1017,6 +1017,27 @@ static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info)
     fw_cfg_add_file(guest_info->fw_cfg, "etc/pci-info", info, sizeof *info);
 }
 
+static void pc_set_cpu_guest_info(CPUState *cpu, void *arg)
+{
+    PcGuestInfo *guest_info = arg;
+    CPUClass *klass = CPU_GET_CLASS(cpu);
+    uint64_t apic_id = klass->get_arch_id(cpu);

Please use "cc" to avoid the dreaded "klass".

Quoted 62 lines
hw/i386/pc.c +28 -0
+    int j;
+
+    assert(apic_id <= MAX_CPUMASK_BITS);
+    assert(apic_id < guest_info->apic_id_limit);
+
+    set_bit(apic_id, guest_info->found_cpus);
+
+    for (j = 0; j < guest_info->numa_nodes; j++) {
+        assert(cpu->cpu_index < max_cpus);
+        if (test_bit(cpu->cpu_index, node_cpumask[j])) {
+            guest_info->node_cpu[apic_id] = cpu_to_le64(j);
+            break;
+        }
+    }
+}
+
 typedef struct PcGuestInfoState {
     PcGuestInfo info;
     Notifier machine_done;
@@ -1037,6 +1058,18 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
     PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
     PcGuestInfo *guest_info = &guest_info_state->info;
 
+    guest_info->ram_size = below_4g_mem_size + above_4g_mem_size;
+    guest_info->apic_id_limit = pc_apic_id_limit(max_cpus);
+    guest_info->apic_xrupt_override = kvm_allows_irq0_override();
+    guest_info->numa_nodes = nb_numa_nodes;
+    guest_info->node_mem = g_memdup(node_mem, guest_info->numa_nodes *
+                                    sizeof *guest_info->node_mem);
+    guest_info->node_cpu = g_malloc0(guest_info->apic_id_limit *
+                                     sizeof *guest_info->node_cpu);
+
+    memset(&guest_info->found_cpus, 0, sizeof guest_info->found_cpus);
+    qemu_for_each_cpu(pc_set_cpu_guest_info, guest_info);
+
     guest_info->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
     if (sizeof(hwaddr) == 4) {
         guest_info->pci_info.w64.begin = 0;
include/hw/i386/pc.h +9 -0
index 7fb97b0..7c0bd50 100644
@@ -9,6 +9,9 @@
 #include "hw/i386/ioapic.h"
 
 #include "qemu/range.h"
+#include "qemu/bitmap.h"
+#include "sysemu/sysemu.h"
+#include "hw/pci/pci.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -17,9 +20,37 @@ typedef struct PcPciInfo {
     Range w64;
 } PcPciInfo;
 
+/* Matches the value hard-coded in BIOS */
+#define PC_GUEST_PORT_ACPI_PM_BASE      0xb000
+
+struct AcpiPmInfo {
+    bool s3_disabled;
+    bool s4_disabled;

include/hw/i386/pc.h typedef struct PcPciInfo { · line 38

Quoted 10 lines
include/hw/i386/pc.h +8 -0
+    uint8_t s4_val;
+    uint16_t sci_int;
+    uint8_t acpi_enable_cmd;
+    uint8_t acpi_disable_cmd;
+    uint32_t gpe0_blk;
+    uint32_t gpe0_blk_len;
+};
+
 struct PcGuestInfo {
     PcPciInfo pci_info;

These capitalizations look weird. Can't we use at least PM rather than Pm?

Andreas

Quoted 30 lines
include/hw/i386/pc.h +14 -0
     bool has_pci_info;
+    hwaddr ram_size;
+    unsigned apic_id_limit;
+    bool apic_xrupt_override;
+    bool has_hpet;
+    uint64_t numa_nodes;
+    uint64_t *node_mem;
+    uint64_t *node_cpu;
+    DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1);
+    DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
+    AcpiPmInfo pm;
+    uint64_t mcfg_base;
+    const unsigned char *dsdt_code;
+    unsigned dsdt_size;
+    uint16_t pvpanic_port;
     FWCfgState *fw_cfg;
 };
 
include/qemu/typedefs.h +1 -0
index ac9f8d4..cb66e19 100644
@@ -65,5 +65,6 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#26 lore raw

Re: [Qemu-devel] [PATCH v3 09/14] i386: define pc guest info

Quoted 104 lines · Andreas Färber

Am 24.07.2013 18:02, schrieb Michael S. Tsirkin:

Quoted 17 lines

This defines a structure that will be used to fill in guest info table. This structure will be filled in in follow-up patches, using QOM. Fill in NUMA node info is not available in QOM so it is filled in directly.

---
 hw/i386/pc.c            | 33 +++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h    | 31 +++++++++++++++++++++++++++++++
 include/qemu/typedefs.h |  1 +
 3 files changed, 65 insertions(+)
hw/i386/pc.c +0 -0
index b0b98a8..b9b8f92 100644

hw/i386/pc.c static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info) · line 1024

Quoted 8 lines
hw/i386/pc.c +5 -0
@@ -1017,6 +1017,27 @@ static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info)
     fw_cfg_add_file(guest_info->fw_cfg, "etc/pci-info", info, sizeof *info);
 }
 
+static void pc_set_cpu_guest_info(CPUState *cpu, void *arg)
+{
+    PcGuestInfo *guest_info = arg;
+    CPUClass *klass = CPU_GET_CLASS(cpu);
+    uint64_t apic_id = klass->get_arch_id(cpu);

Please use "cc" to avoid the dreaded "klass".

Quoted 62 lines
hw/i386/pc.c +28 -0
+    int j;
+
+    assert(apic_id <= MAX_CPUMASK_BITS);
+    assert(apic_id < guest_info->apic_id_limit);
+
+    set_bit(apic_id, guest_info->found_cpus);
+
+    for (j = 0; j < guest_info->numa_nodes; j++) {
+        assert(cpu->cpu_index < max_cpus);
+        if (test_bit(cpu->cpu_index, node_cpumask[j])) {
+            guest_info->node_cpu[apic_id] = cpu_to_le64(j);
+            break;
+        }
+    }
+}
+
 typedef struct PcGuestInfoState {
     PcGuestInfo info;
     Notifier machine_done;
@@ -1037,6 +1058,18 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
     PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
     PcGuestInfo *guest_info = &guest_info_state->info;
 
+    guest_info->ram_size = below_4g_mem_size + above_4g_mem_size;
+    guest_info->apic_id_limit = pc_apic_id_limit(max_cpus);
+    guest_info->apic_xrupt_override = kvm_allows_irq0_override();
+    guest_info->numa_nodes = nb_numa_nodes;
+    guest_info->node_mem = g_memdup(node_mem, guest_info->numa_nodes *
+                                    sizeof *guest_info->node_mem);
+    guest_info->node_cpu = g_malloc0(guest_info->apic_id_limit *
+                                     sizeof *guest_info->node_cpu);
+
+    memset(&guest_info->found_cpus, 0, sizeof guest_info->found_cpus);
+    qemu_for_each_cpu(pc_set_cpu_guest_info, guest_info);
+
     guest_info->pci_info.w32.end = IO_APIC_DEFAULT_ADDRESS;
     if (sizeof(hwaddr) == 4) {
         guest_info->pci_info.w64.begin = 0;
include/hw/i386/pc.h +9 -0
index 7fb97b0..7c0bd50 100644
@@ -9,6 +9,9 @@
 #include "hw/i386/ioapic.h"
 
 #include "qemu/range.h"
+#include "qemu/bitmap.h"
+#include "sysemu/sysemu.h"
+#include "hw/pci/pci.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -17,9 +20,37 @@ typedef struct PcPciInfo {
     Range w64;
 } PcPciInfo;
 
+/* Matches the value hard-coded in BIOS */
+#define PC_GUEST_PORT_ACPI_PM_BASE      0xb000
+
+struct AcpiPmInfo {
+    bool s3_disabled;
+    bool s4_disabled;

include/hw/i386/pc.h typedef struct PcPciInfo { · line 38

Quoted 10 lines
include/hw/i386/pc.h +8 -0
+    uint8_t s4_val;
+    uint16_t sci_int;
+    uint8_t acpi_enable_cmd;
+    uint8_t acpi_disable_cmd;
+    uint32_t gpe0_blk;
+    uint32_t gpe0_blk_len;
+};
+
 struct PcGuestInfo {
     PcPciInfo pci_info;

These capitalizations look weird. Can't we use at least PM rather than Pm?

Quoted 1 line

Andreas

I prefer making a first letter in each work upper case consistently but I don't mind so much.

Quoted 35 lines
Quoted 30 lines
include/hw/i386/pc.h +14 -0
     bool has_pci_info;
+    hwaddr ram_size;
+    unsigned apic_id_limit;
+    bool apic_xrupt_override;
+    bool has_hpet;
+    uint64_t numa_nodes;
+    uint64_t *node_mem;
+    uint64_t *node_cpu;
+    DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1);
+    DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
+    AcpiPmInfo pm;
+    uint64_t mcfg_base;
+    const unsigned char *dsdt_code;
+    unsigned dsdt_size;
+    uint16_t pvpanic_port;
     FWCfgState *fw_cfg;
 };
 
include/qemu/typedefs.h +1 -0
index ac9f8d4..cb66e19 100644
@@ -65,5 +65,6 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#27 lore raw

PATCH v3 10/14 ich9: APIs for pc guest info

In reply to Michael S. Tsirkin

This adds APIs that will be used to fill in
guest info table, implemented using QOM,
to various ich9 components.

---
 hw/acpi/ich9.c            |  6 ++++++
 hw/isa/lpc_ich9.c         | 19 +++++++++++++++++++
 hw/pci-host/q35.c         | 10 ++++++++++
 include/hw/acpi/ich9.h    |  2 ++
 include/hw/i386/ich9.h    |  3 +++
 include/hw/pci-host/q35.h |  2 ++
 6 files changed, 42 insertions(+)
hw/acpi/ich9.c +6 -0
index 3fb443d..7ea55e1 100644
@@ -228,3 +228,9 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
     pm->powerdown_notifier.notify = pm_powerdown_req;
     qemu_register_powerdown_notifier(&pm->powerdown_notifier);
 }
+
+void ich9_pm_get_acpi_pm_info(ICH9LPCPMRegs *pm, AcpiPmInfo *info)
+{
+    info->gpe0_blk = PC_GUEST_PORT_ACPI_PM_BASE + ICH9_PMIO_GPE0_STS;
+    info->gpe0_blk_len = ICH9_PMIO_GPE0_LEN;
+}
hw/isa/lpc_ich9.c +19 -0
index d1921aa..12d4a23 100644
@@ -562,6 +562,25 @@ static bool ich9_rst_cnt_needed(void *opaque)
     return (lpc->rst_cnt != 0);
 }
 
+ICH9LPCState *ich9_lpc_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", TYPE_ICH9_LPC_DEVICE, &ambig);
+
+    if (ambig) {
+        return NULL;
+    }
+    return ICH9_LPC_DEVICE(o);
+}
+
+void ich9_lpc_get_acpi_pm_info(ICH9LPCState *lpc, AcpiPmInfo *info)
+{
+    info->sci_int = 9;
+    info->acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
+    info->acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
+    ich9_pm_get_acpi_pm_info(&lpc->pm, info);
+}
+
 static const VMStateDescription vmstate_ich9_rst_cnt = {
     .name = "ICH9LPC/rst_cnt",
     .version_id = 1,
hw/pci-host/q35.c +10 -0
index 6b1b3b7..ca6f495 100644
@@ -298,6 +298,16 @@ static int mch_init(PCIDevice *d)
     return 0;
 }
 
+uint64_t mch_mcfg_base(void)
+{
+    bool ambiguous;
+    Object *o = object_resolve_path_type("", TYPE_MCH_PCI_DEVICE, &ambiguous);
+    if (!o) {
+        return 0;
+    }
+    return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
+}
+
 static void mch_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
include/hw/acpi/ich9.h +2 -0
index b1fe71f..f5e8a88 100644
@@ -49,4 +49,6 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
 void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base);
 extern const VMStateDescription vmstate_ich9_pm;
 
+void ich9_pm_get_acpi_pm_info(ICH9LPCPMRegs *, AcpiPmInfo *);
+
 #endif /* HW_ACPI_ICH9_H */
include/hw/i386/ich9.h +3 -0
index c5f637b..6528dc0 100644
@@ -66,6 +66,9 @@ typedef struct ICH9LPCState {
     qemu_irq *ioapic;
 } ICH9LPCState;
 
+ICH9LPCState *ich9_lpc_find(void);
+void ich9_lpc_get_acpi_pm_info(ICH9LPCState *, AcpiPmInfo *);
+
 #define Q35_MASK(bit, ms_bit, ls_bit) \
 ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
 
include/hw/pci-host/q35.h +2 -0
index 3cb631e..6337dcf 100644
@@ -154,4 +154,6 @@ typedef struct Q35PCIHost {
 #define MCH_PCIE_DEV                           1
 #define MCH_PCIE_FUNC                          0
 
+uint64_t mch_mcfg_base(void);
+
 #endif /* HW_Q35_H */
Signature · 1 line
MST
Reviewed-by on v3 10/14
#28 lore raw

Re: [Qemu-devel] [PATCH v3 10/14] ich9: APIs for pc guest info

Quoted 3 lines · Michael S. Tsirkin

This adds APIs that will be used to fill in
guest info table, implemented using QOM,
to various ich9 components.

Uses QOM to lookup the device state without needing nasty hooks in machine creation. Then goes copy info directly from device state as the bits needed are not exported as properties. Looks reasonable to me.

cheers,
Gerd

#29 lore raw

Re: [Qemu-devel] [PATCH v3 10/14] ich9: APIs for pc guest info

In reply to Michael S. Tsirkin

Am 24.07.2013 18:02, schrieb Michael S. Tsirkin:

Quoted 40 lines

This adds APIs that will be used to fill in
guest info table, implemented using QOM,
to various ich9 components.

---
 hw/acpi/ich9.c            |  6 ++++++
 hw/isa/lpc_ich9.c         | 19 +++++++++++++++++++
 hw/pci-host/q35.c         | 10 ++++++++++
 include/hw/acpi/ich9.h    |  2 ++
 include/hw/i386/ich9.h    |  3 +++
 include/hw/pci-host/q35.h |  2 ++
 6 files changed, 42 insertions(+)
hw/acpi/ich9.c +6 -0
index 3fb443d..7ea55e1 100644
@@ -228,3 +228,9 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
     pm->powerdown_notifier.notify = pm_powerdown_req;
     qemu_register_powerdown_notifier(&pm->powerdown_notifier);
 }
+
+void ich9_pm_get_acpi_pm_info(ICH9LPCPMRegs *pm, AcpiPmInfo *info)
+{
+    info->gpe0_blk = PC_GUEST_PORT_ACPI_PM_BASE + ICH9_PMIO_GPE0_STS;
+    info->gpe0_blk_len = ICH9_PMIO_GPE0_LEN;
+}
hw/isa/lpc_ich9.c +4 -0
index d1921aa..12d4a23 100644
@@ -562,6 +562,25 @@ static bool ich9_rst_cnt_needed(void *opaque)
     return (lpc->rst_cnt != 0);
 }
 
+ICH9LPCState *ich9_lpc_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", TYPE_ICH9_LPC_DEVICE, &ambig);

hw/isa/lpc_ich9.c static bool ich9_rst_cnt_needed(void *opaque) · line 578

Quoted 10 lines
hw/isa/lpc_ich9.c +10 -0
+
+    if (ambig) {
+        return NULL;
+    }
+    return ICH9_LPC_DEVICE(o);
+}
+
+void ich9_lpc_get_acpi_pm_info(ICH9LPCState *lpc, AcpiPmInfo *info)
+{
+    info->sci_int = 9;

Magic value.

Quoted 13 lines
hw/isa/lpc_ich9.c +5 -0
+    info->acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
+    info->acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
+    ich9_pm_get_acpi_pm_info(&lpc->pm, info);
+}
+
 static const VMStateDescription vmstate_ich9_rst_cnt = {
     .name = "ICH9LPC/rst_cnt",
     .version_id = 1,
hw/pci-host/q35.c +0 -0
index 6b1b3b7..ca6f495 100644

hw/pci-host/q35.c static int mch_init(PCIDevice *d) · line 304

Quoted 7 lines
hw/pci-host/q35.c +4 -0
@@ -298,6 +298,16 @@ static int mch_init(PCIDevice *d)
     return 0;
 }
 
+uint64_t mch_mcfg_base(void)
+{
+    bool ambiguous;
+    Object *o = object_resolve_path_type("", TYPE_MCH_PCI_DEVICE, &ambiguous);

If you take the minute to add in q35 machine init object_property_add_child(qdev_get_machine(), "q35", foo, NULL); then not only can you use object_resolve_path("/machine/q35/mch") to access it but everyone including qtest can.

hw/pci-host/q35.c static int mch_init(PCIDevice *d) · line 308

Quoted 4 lines
hw/pci-host/q35.c +4 -0
+    if (!o) {
+        return 0;
+    }
+    return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;

Another value constant for the device. Taking a wild guess: Is this an offset of a memory subregion where long-term Anthony's proposed MemoryRegion QOM'ification would allow us to get rid of this helper?

Anyway, I would like it much better as:

uint64_t mch_mcfg_base()

{
    return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
}

with the path resolution stuff, i.e. check for necessity, happening in ACPI code, if we don't get around these helpers for now.

Andreas

Quoted 42 lines
hw/pci-host/q35.c +2 -0
+}
+
 static void mch_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
include/hw/acpi/ich9.h +2 -0
index b1fe71f..f5e8a88 100644
@@ -49,4 +49,6 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
 void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base);
 extern const VMStateDescription vmstate_ich9_pm;
 
+void ich9_pm_get_acpi_pm_info(ICH9LPCPMRegs *, AcpiPmInfo *);
+
 #endif /* HW_ACPI_ICH9_H */
include/hw/i386/ich9.h +3 -0
index c5f637b..6528dc0 100644
@@ -66,6 +66,9 @@ typedef struct ICH9LPCState {
     qemu_irq *ioapic;
 } ICH9LPCState;
 
+ICH9LPCState *ich9_lpc_find(void);
+void ich9_lpc_get_acpi_pm_info(ICH9LPCState *, AcpiPmInfo *);
+
 #define Q35_MASK(bit, ms_bit, ls_bit) \
 ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
 
include/hw/pci-host/q35.h +2 -0
index 3cb631e..6337dcf 100644
@@ -154,4 +154,6 @@ typedef struct Q35PCIHost {
 #define MCH_PCIE_DEV                           1
 #define MCH_PCIE_FUNC                          0
 
+uint64_t mch_mcfg_base(void);
+
 #endif /* HW_Q35_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#30 lore raw

Re: [Qemu-devel] [PATCH v3 10/14] ich9: APIs for pc guest info

Quoted 70 lines · Andreas Färber

Am 24.07.2013 18:02, schrieb Michael S. Tsirkin:

Quoted 40 lines

This adds APIs that will be used to fill in
guest info table, implemented using QOM,
to various ich9 components.

---
 hw/acpi/ich9.c            |  6 ++++++
 hw/isa/lpc_ich9.c         | 19 +++++++++++++++++++
 hw/pci-host/q35.c         | 10 ++++++++++
 include/hw/acpi/ich9.h    |  2 ++
 include/hw/i386/ich9.h    |  3 +++
 include/hw/pci-host/q35.h |  2 ++
 6 files changed, 42 insertions(+)
hw/acpi/ich9.c +6 -0
index 3fb443d..7ea55e1 100644
@@ -228,3 +228,9 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
     pm->powerdown_notifier.notify = pm_powerdown_req;
     qemu_register_powerdown_notifier(&pm->powerdown_notifier);
 }
+
+void ich9_pm_get_acpi_pm_info(ICH9LPCPMRegs *pm, AcpiPmInfo *info)
+{
+    info->gpe0_blk = PC_GUEST_PORT_ACPI_PM_BASE + ICH9_PMIO_GPE0_STS;
+    info->gpe0_blk_len = ICH9_PMIO_GPE0_LEN;
+}
hw/isa/lpc_ich9.c +4 -0
index d1921aa..12d4a23 100644
@@ -562,6 +562,25 @@ static bool ich9_rst_cnt_needed(void *opaque)
     return (lpc->rst_cnt != 0);
 }
 
+ICH9LPCState *ich9_lpc_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", TYPE_ICH9_LPC_DEVICE, &ambig);

hw/isa/lpc_ich9.c static bool ich9_rst_cnt_needed(void *opaque) · line 578

Quoted 10 lines
hw/isa/lpc_ich9.c +10 -0
+
+    if (ambig) {
+        return NULL;
+    }
+    return ICH9_LPC_DEVICE(o);
+}
+
+void ich9_lpc_get_acpi_pm_info(ICH9LPCState *lpc, AcpiPmInfo *info)
+{
+    info->sci_int = 9;

Magic value.

Quoted 16 lines
hw/isa/lpc_ich9.c +5 -0
+    info->acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
+    info->acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
+    ich9_pm_get_acpi_pm_info(&lpc->pm, info);
+}
+
 static const VMStateDescription vmstate_ich9_rst_cnt = {
     .name = "ICH9LPC/rst_cnt",
     .version_id = 1,
hw/pci-host/q35.c +0 -0
index 6b1b3b7..ca6f495 100644
@@ -298,6 +298,16 @@ static int mch_init(PCIDevice *d)
     return 0;
 }
 
Quoted 9 lines

hw/pci-host/q35.c static int mch_init(PCIDevice *d) · line 304

Quoted 4 lines
hw/pci-host/q35.c +4 -0
+uint64_t mch_mcfg_base(void)
+{
+    bool ambiguous;
+    Object *o = object_resolve_path_type("", TYPE_MCH_PCI_DEVICE, &ambiguous);

If you take the minute to add in q35 machine init object_property_add_child(qdev_get_machine(), "q35", foo, NULL); then not only can you use object_resolve_path("/machine/q35/mch") to access it but everyone including qtest can.

That's fine but I'd like to avoid copying string literals around.

Quoted 8 lines

hw/pci-host/q35.c static int mch_init(PCIDevice *d) · line 308

Quoted 4 lines
hw/pci-host/q35.c +4 -0
+    if (!o) {
+        return 0;
+    }
+    return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;

Another value constant for the device. Taking a wild guess: Is this an offset of a memory subregion where long-term Anthony's proposed MemoryRegion QOM'ification would allow us to get rid of this helper?

I'm not sure that will be possible because the offset it programmable by guest. At the moment all guests are required to program a hard-coded offset, but I think what we'll have long term, is a guest interface that let us control what guest programs.

Quoted 59 lines

Anyway, I would like it much better as:

uint64_t mch_mcfg_base()

{
    return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
}

with the path resolution stuff, i.e. check for necessity, happening in ACPI code, if we don't get around these helpers for now.

Andreas

Quoted 42 lines
hw/pci-host/q35.c +2 -0
+}
+
 static void mch_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
include/hw/acpi/ich9.h +2 -0
index b1fe71f..f5e8a88 100644
@@ -49,4 +49,6 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
 void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base);
 extern const VMStateDescription vmstate_ich9_pm;
 
+void ich9_pm_get_acpi_pm_info(ICH9LPCPMRegs *, AcpiPmInfo *);
+
 #endif /* HW_ACPI_ICH9_H */
include/hw/i386/ich9.h +3 -0
index c5f637b..6528dc0 100644
@@ -66,6 +66,9 @@ typedef struct ICH9LPCState {
     qemu_irq *ioapic;
 } ICH9LPCState;
 
+ICH9LPCState *ich9_lpc_find(void);
+void ich9_lpc_get_acpi_pm_info(ICH9LPCState *, AcpiPmInfo *);
+
 #define Q35_MASK(bit, ms_bit, ls_bit) \
 ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
 
include/hw/pci-host/q35.h +2 -0
index 3cb631e..6337dcf 100644
@@ -154,4 +154,6 @@ typedef struct Q35PCIHost {
 #define MCH_PCIE_DEV                           1
 #define MCH_PCIE_FUNC                          0
 
+uint64_t mch_mcfg_base(void);
+
 #endif /* HW_Q35_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#31 lore raw

PATCH v3 11/14 piix: APIs for pc guest info

In reply to Michael S. Tsirkin

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---
 hw/acpi/piix4.c         | 29 +++++++++++++++++++++++++++--
 hw/mips/mips_malta.c    |  2 +-
 hw/pci-host/piix.c      |  8 ++++++++
 include/hw/i386/pc.h    |  1 +
 include/qemu/typedefs.h |  1 +
 5 files changed, 38 insertions(+), 3 deletions(-)
hw/acpi/piix4.c +27 -2
index c885690..2128f13 100644
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
+#include "hw/acpi/piix4.h"
 
 //#define DEBUG
 
@@ -63,7 +64,7 @@ typedef struct CPUStatus {
     uint8_t sts[PIIX4_PROC_LEN];
 } CPUStatus;
 
-typedef struct PIIX4PMState {
+struct PIIX4PMState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/
@@ -96,7 +97,7 @@ typedef struct PIIX4PMState {
 
     CPUStatus gpe_cpu;
     Notifier cpu_added_notifier;
-} PIIX4PMState;
+};
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 
@@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev)
     return 0;
 }
 
+PIIX4PMState *piix4_pm_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig);
+
+    if (ambig || !o) {
+        return NULL;
+    }
+    return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM");
+}
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info)
+{
+        info->s3_disabled = s->disable_s3;
+        info->s4_disabled = s->disable_s4;
+        info->s4_val = s->s4_val;
+
+        info->acpi_enable_cmd = ACPI_ENABLE;
+        info->acpi_disable_cmd = ACPI_DISABLE;
+        info->gpe0_blk = GPE_BASE;
+        info->gpe0_blk_len = GPE_LEN;
+        info->sci_int = 9;
+}
+
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
                        int kvm_enabled, FWCfgState *fw_cfg)
hw/mips/mips_malta.c +1 -1
index de87241..14573ab 100644
@@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
-                          isa_get_irq(NULL, 9), NULL, 0, NULL);
+                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
     pit = pit_init(isa_bus, 0x40, 0, NULL);
hw/pci-host/piix.c +8 -0
index 3908860..daefdfb 100644
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);
+    return s ? s->bus : NULL;
+}
+
 /* PIIX3 PCI to ISA bridge */
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
include/hw/i386/pc.h +1 -0
index 7c0bd50..76af5cd 100644
@@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
                     MemoryRegion *pci_memory,
                     MemoryRegion *ram_memory);
 
+PCIBus *find_i440fx(void);
 /* piix4.c */
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
include/qemu/typedefs.h +1 -0
index cb66e19..7d42693 100644
@@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct PIIX4PMState PIIX4PMState;
 typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 1 line
MST
#32 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Quoted 11 lines · Michael S. Tsirkin

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---
 hw/acpi/piix4.c         | 29 +++++++++++++++++++++++++++--
 hw/mips/mips_malta.c    |  2 +-
 hw/pci-host/piix.c      |  8 ++++++++
 include/hw/i386/pc.h    |  1 +
 include/qemu/typedefs.h |  1 +
 5 files changed, 38 insertions(+), 3 deletions(-)

Ouch, forgot to git add a file, so it's missing.
include/hw/acpi/piix4.h below.
Corrected patch with this chunk added below.
It's trivial so not reposting.

--->

Subject: piix: APIs for pc guest info

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---

hw/acpi/piix4.c +27 -2
index c885690..2128f13 100644
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
+#include "hw/acpi/piix4.h"
 
 //#define DEBUG
 
@@ -63,7 +64,7 @@ typedef struct CPUStatus {
     uint8_t sts[PIIX4_PROC_LEN];
 } CPUStatus;
 
-typedef struct PIIX4PMState {
+struct PIIX4PMState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/
@@ -96,7 +97,7 @@ typedef struct PIIX4PMState {
 
     CPUStatus gpe_cpu;
     Notifier cpu_added_notifier;
-} PIIX4PMState;
+};
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 
@@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev)
     return 0;
 }
 
+PIIX4PMState *piix4_pm_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig);
+
+    if (ambig || !o) {
+        return NULL;
+    }
+    return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM");
+}
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info)
+{
+        info->s3_disabled = s->disable_s3;
+        info->s4_disabled = s->disable_s4;
+        info->s4_val = s->s4_val;
+
+        info->acpi_enable_cmd = ACPI_ENABLE;
+        info->acpi_disable_cmd = ACPI_DISABLE;
+        info->gpe0_blk = GPE_BASE;
+        info->gpe0_blk_len = GPE_LEN;
+        info->sci_int = 9;
+}
+
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
                        int kvm_enabled, FWCfgState *fw_cfg)
hw/mips/mips_malta.c +1 -1
index de87241..14573ab 100644
@@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
-                          isa_get_irq(NULL, 9), NULL, 0, NULL);
+                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
     pit = pit_init(isa_bus, 0x40, 0, NULL);
hw/pci-host/piix.c +8 -0
index 3908860..daefdfb 100644
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);
+    return s ? s->bus : NULL;
+}
+
 /* PIIX3 PCI to ISA bridge */
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
include/hw/acpi/piix4.h new file +10 -0
new file mode 100644
index 0000000..2876428
@@ -0,0 +1,10 @@
+#ifndef HW_ACPI_PIIX4_H
+#define HW_ACPI_PIIX4_H
+
+#include "qemu/typedefs.h"
+
+PIIX4PMState *piix4_pm_find(void);
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *, AcpiPmInfo *);
+
+#endif
include/hw/i386/pc.h +1 -0
index 7c0bd50..76af5cd 100644
@@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
                     MemoryRegion *pci_memory,
                     MemoryRegion *ram_memory);
 
+PCIBus *find_i440fx(void);
 /* piix4.c */
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
include/qemu/typedefs.h +1 -0
index cb66e19..7d42693 100644
@@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct PIIX4PMState PIIX4PMState;
 typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
#33 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

Quoted 28 lines

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---

hw/acpi/piix4.c +2 -1
index c885690..2128f13 100644
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
+#include "hw/acpi/piix4.h"
 
 //#define DEBUG
 
@@ -63,7 +64,7 @@ typedef struct CPUStatus {
     uint8_t sts[PIIX4_PROC_LEN];
 } CPUStatus;
 
-typedef struct PIIX4PMState {
+struct PIIX4PMState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/

hw/acpi/piix4.c typedef struct PIIX4PMState { · line 103

Quoted 8 lines
hw/acpi/piix4.c +1 -1
@@ -96,7 +97,7 @@ typedef struct PIIX4PMState {
 
     CPUStatus gpe_cpu;
     Notifier cpu_added_notifier;
-} PIIX4PMState;
+};
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 

Here add

#define PIIX4_PM(obj) OBJECT_CHECK(PIIX4PMState, obj, TYPE_PIIX4_PM)

for the general public ...

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 470

Quoted 13 lines
hw/acpi/piix4.c +9 -0
@@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev)
     return 0;
 }
 
+PIIX4PMState *piix4_pm_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig);
+
+    if (ambig || !o) {
+        return NULL;
+    }
+    return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM");

... instead of open-coding it where only you use it, please.

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 477

Quoted 7 lines
hw/acpi/piix4.c +7 -0
+}
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info)
+{
+        info->s3_disabled = s->disable_s3;
+        info->s4_disabled = s->disable_s4;
+        info->s4_val = s->s4_val;

These three are accessible as qdev/QOM properties.

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 482

Quoted 5 lines
hw/acpi/piix4.c +5 -0
+
+        info->acpi_enable_cmd = ACPI_ENABLE;
+        info->acpi_disable_cmd = ACPI_DISABLE;
+        info->gpe0_blk = GPE_BASE;
+        info->gpe0_blk_len = GPE_LEN;

So here the issue is that values are constant?

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 483

Quoted 1 line
hw/acpi/piix4.c +1 -0
+        info->sci_int = 9;

Magic number - use a define to share it with wherever it is used?

Quoted 10 lines
hw/acpi/piix4.c +2 -0
+}
+
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
                        int kvm_enabled, FWCfgState *fw_cfg)
hw/mips/mips_malta.c +0 -0
index de87241..14573ab 100644

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 968

Quoted 5 lines
hw/mips/mips_malta.c +1 -1
@@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
-                          isa_get_irq(NULL, 9), NULL, 0, NULL);
+                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);

This looks fishy. Might belong into a different patch? Implementation didn't change above.

Quoted 8 lines
hw/mips/mips_malta.c +0 -0
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
     pit = pit_init(isa_bus, 0x40, 0, NULL);
hw/pci-host/piix.c +0 -0
index 3908860..daefdfb 100644

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 8 lines
hw/pci-host/piix.c +5 -0
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

Andreas

Quoted 45 lines
hw/pci-host/piix.c +1 -0
+
 /* PIIX3 PCI to ISA bridge */
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
include/hw/acpi/piix4.h new file +10 -0
new file mode 100644
index 0000000..2876428
@@ -0,0 +1,10 @@
+#ifndef HW_ACPI_PIIX4_H
+#define HW_ACPI_PIIX4_H
+
+#include "qemu/typedefs.h"
+
+PIIX4PMState *piix4_pm_find(void);
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *, AcpiPmInfo *);
+
+#endif
include/hw/i386/pc.h +1 -0
index 7c0bd50..76af5cd 100644
@@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
                     MemoryRegion *pci_memory,
                     MemoryRegion *ram_memory);
 
+PCIBus *find_i440fx(void);
 /* piix4.c */
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
include/qemu/typedefs.h +1 -0
index cb66e19..7d42693 100644
@@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct PIIX4PMState PIIX4PMState;
 typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#34 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Quoted 48 lines · Andreas Färber

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

Quoted 28 lines

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---

hw/acpi/piix4.c +2 -1
index c885690..2128f13 100644
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
+#include "hw/acpi/piix4.h"
 
 //#define DEBUG
 
@@ -63,7 +64,7 @@ typedef struct CPUStatus {
     uint8_t sts[PIIX4_PROC_LEN];
 } CPUStatus;
 
-typedef struct PIIX4PMState {
+struct PIIX4PMState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/

hw/acpi/piix4.c typedef struct PIIX4PMState { · line 103

Quoted 8 lines
hw/acpi/piix4.c +1 -1
@@ -96,7 +97,7 @@ typedef struct PIIX4PMState {
 
     CPUStatus gpe_cpu;
     Notifier cpu_added_notifier;
-} PIIX4PMState;
+};
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 

Here add

#define PIIX4_PM(obj) OBJECT_CHECK(PIIX4PMState, obj, TYPE_PIIX4_PM)

for the general public ...

Quoted 4 lines
hw/acpi/piix4.c +0 -0
@@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev)
     return 0;
 }
 
Quoted 11 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 470

Quoted 9 lines
hw/acpi/piix4.c +9 -0
+PIIX4PMState *piix4_pm_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig);
+
+    if (ambig || !o) {
+        return NULL;
+    }
+    return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM");

... instead of open-coding it where only you use it, please.

I don't really understand in which direction you want to take this. On the one hand, you are saying "there's one caller of this function so please open-code it".
On the other hand, you are saying "it does not matter that there's one user of this macro put it in the header".

Is the point that macros are somehow better than functions so they should be used where possible?

Quoted 10 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 477

Quoted 7 lines
hw/acpi/piix4.c +7 -0
+}
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info)
+{
+        info->s3_disabled = s->disable_s3;
+        info->s4_disabled = s->disable_s4;
+        info->s4_val = s->s4_val;

These three are accessible as qdev/QOM properties.

Quoted 7 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 482

Quoted 5 lines
hw/acpi/piix4.c +5 -0
+
+        info->acpi_enable_cmd = ACPI_ENABLE;
+        info->acpi_disable_cmd = ACPI_DISABLE;
+        info->gpe0_blk = GPE_BASE;
+        info->gpe0_blk_len = GPE_LEN;

So here the issue is that values are constant?

Yes.

Quoted 45 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 483

Quoted 1 line
hw/acpi/piix4.c +1 -0
+        info->sci_int = 9;

Magic number - use a define to share it with wherever it is used?

Quoted 10 lines
hw/acpi/piix4.c +2 -0
+}
+
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
                        int kvm_enabled, FWCfgState *fw_cfg)
hw/mips/mips_malta.c +0 -0
index de87241..14573ab 100644

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 968

Quoted 5 lines
hw/mips/mips_malta.c +1 -1
@@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
-                          isa_get_irq(NULL, 9), NULL, 0, NULL);
+                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);

This looks fishy. Might belong into a different patch? Implementation didn't change above.

Quoted 8 lines
hw/mips/mips_malta.c +0 -0
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
     pit = pit_init(isa_bus, 0x40, 0, NULL);
hw/pci-host/piix.c +0 -0
index 3908860..daefdfb 100644

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 8 lines
hw/pci-host/piix.c +5 -0
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}
Quoted 6 lines

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

Andreas

I don't mind but I would like to avoid callers hard-coding paths, in this case "i440fx".
Why the aversion to functions?

Quoted 50 lines
Quoted 45 lines
hw/pci-host/piix.c +1 -0
+
 /* PIIX3 PCI to ISA bridge */
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
include/hw/acpi/piix4.h new file +10 -0
new file mode 100644
index 0000000..2876428
@@ -0,0 +1,10 @@
+#ifndef HW_ACPI_PIIX4_H
+#define HW_ACPI_PIIX4_H
+
+#include "qemu/typedefs.h"
+
+PIIX4PMState *piix4_pm_find(void);
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *, AcpiPmInfo *);
+
+#endif
include/hw/i386/pc.h +1 -0
index 7c0bd50..76af5cd 100644
@@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
                     MemoryRegion *pci_memory,
                     MemoryRegion *ram_memory);
 
+PCIBus *find_i440fx(void);
 /* piix4.c */
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
include/qemu/typedefs.h +1 -0
index cb66e19..7d42693 100644
@@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct PIIX4PMState PIIX4PMState;
 typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#35 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Am 28.07.2013 09:30, schrieb Michael S. Tsirkin:

Quoted 61 lines · Andreas Färber
Quoted 48 lines

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

Quoted 28 lines

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---

hw/acpi/piix4.c +2 -1
index c885690..2128f13 100644
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
+#include "hw/acpi/piix4.h"
 
 //#define DEBUG
 
@@ -63,7 +64,7 @@ typedef struct CPUStatus {
     uint8_t sts[PIIX4_PROC_LEN];
 } CPUStatus;
 
-typedef struct PIIX4PMState {
+struct PIIX4PMState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/

hw/acpi/piix4.c typedef struct PIIX4PMState { · line 103

Quoted 8 lines
hw/acpi/piix4.c +1 -1
@@ -96,7 +97,7 @@ typedef struct PIIX4PMState {
 
     CPUStatus gpe_cpu;
     Notifier cpu_added_notifier;
-} PIIX4PMState;
+};
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 

Here add

#define PIIX4_PM(obj) OBJECT_CHECK(PIIX4PMState, obj, TYPE_PIIX4_PM)

for the general public ...

Quoted 4 lines
hw/acpi/piix4.c +0 -0
@@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev)
     return 0;
 }
 
Quoted 11 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 470

Quoted 9 lines
hw/acpi/piix4.c +9 -0
+PIIX4PMState *piix4_pm_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig);
+
+    if (ambig || !o) {
+        return NULL;
+    }
+    return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM");

... instead of open-coding it where only you use it, please.

Quoted 8 lines

I don't really understand in which direction you want to take this. On the one hand, you are saying "there's one caller of this function so please open-code it".
On the other hand, you are saying "it does not matter that there's one user of this macro put it in the header".

Is the point that macros are somehow better than functions so they should be used where possible?

No, the point is reuse: For QOM realize we will very likely need the same thing. It was not my decision to make these macros, I'm just making Anthony's QOM pattern consistent.

Quoted 71 lines
Quoted 10 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 477

Quoted 7 lines
hw/acpi/piix4.c +7 -0
+}
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info)
+{
+        info->s3_disabled = s->disable_s3;
+        info->s4_disabled = s->disable_s4;
+        info->s4_val = s->s4_val;

These three are accessible as qdev/QOM properties.

Quoted 7 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 482

Quoted 5 lines
hw/acpi/piix4.c +5 -0
+
+        info->acpi_enable_cmd = ACPI_ENABLE;
+        info->acpi_disable_cmd = ACPI_DISABLE;
+        info->gpe0_blk = GPE_BASE;
+        info->gpe0_blk_len = GPE_LEN;

So here the issue is that values are constant?

Yes.

Quoted 42 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 483

Quoted 1 line
hw/acpi/piix4.c +1 -0
+        info->sci_int = 9;

Magic number - use a define to share it with wherever it is used?

Quoted 10 lines
hw/acpi/piix4.c +2 -0
+}
+
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
                        int kvm_enabled, FWCfgState *fw_cfg)
hw/mips/mips_malta.c +0 -0
index de87241..14573ab 100644

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 968

Quoted 5 lines
hw/mips/mips_malta.c +1 -1
@@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
-                          isa_get_irq(NULL, 9), NULL, 0, NULL);
+                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);

This looks fishy. Might belong into a different patch? Implementation didn't change above.

Quoted 8 lines
hw/mips/mips_malta.c +0 -0
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
     pit = pit_init(isa_bus, 0x40, 0, NULL);
hw/pci-host/piix.c +0 -0
index 3908860..daefdfb 100644

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 8 lines
hw/pci-host/piix.c +5 -0
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

Quoted 7 lines

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

Quoted 3 lines

I don't mind but I would like to avoid callers hard-coding paths, in this case "i440fx".
Why the aversion to functions?

Simply because QMP cannot call functions. It has to work with qom-list and qom-get, so this is a test case showing what is missing and can IMO easily be addressed for both parties.

The suggested cast to PCI_BUS() lets you use regular qdev functions btw as a shortcut, QMP users would need to iterate children of that node.

The suggested "pci.0" is considered stable for -device ...,bus=pci.0 according to review feedback the Xen people have received for libxl.

Andreas

Quoted 51 lines
Quoted 51 lines
Quoted 46 lines
hw/pci-host/piix.c +1 -0
+
 /* PIIX3 PCI to ISA bridge */
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
include/hw/acpi/piix4.h new file +10 -0
new file mode 100644
index 0000000..2876428
@@ -0,0 +1,10 @@
+#ifndef HW_ACPI_PIIX4_H
+#define HW_ACPI_PIIX4_H
+
+#include "qemu/typedefs.h"
+
+PIIX4PMState *piix4_pm_find(void);
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *, AcpiPmInfo *);
+
+#endif
include/hw/i386/pc.h +1 -0
index 7c0bd50..76af5cd 100644
@@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
                     MemoryRegion *pci_memory,
                     MemoryRegion *ram_memory);
 
+PCIBus *find_i440fx(void);
 /* piix4.c */
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
include/qemu/typedefs.h +1 -0
index cb66e19..7d42693 100644
@@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct PIIX4PMState PIIX4PMState;
 typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#36 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Quoted 146 lines · Andreas Färber

Am 28.07.2013 09:30, schrieb Michael S. Tsirkin:

Quoted 61 lines · Andreas Färber
Quoted 48 lines

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

Quoted 28 lines

This adds APIs that will be used to fill in guest info table, implemented using QOM, to various piix components.

---

hw/acpi/piix4.c +2 -1
index c885690..2128f13 100644
@@ -29,6 +29,7 @@
 #include "exec/ioport.h"
 #include "hw/nvram/fw_cfg.h"
 #include "exec/address-spaces.h"
+#include "hw/acpi/piix4.h"
 
 //#define DEBUG
 
@@ -63,7 +64,7 @@ typedef struct CPUStatus {
     uint8_t sts[PIIX4_PROC_LEN];
 } CPUStatus;
 
-typedef struct PIIX4PMState {
+struct PIIX4PMState {
     /*< private >*/
     PCIDevice parent_obj;
     /*< public >*/

hw/acpi/piix4.c typedef struct PIIX4PMState { · line 103

Quoted 8 lines
hw/acpi/piix4.c +1 -1
@@ -96,7 +97,7 @@ typedef struct PIIX4PMState {
 
     CPUStatus gpe_cpu;
     Notifier cpu_added_notifier;
-} PIIX4PMState;
+};
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 

Here add

#define PIIX4_PM(obj) OBJECT_CHECK(PIIX4PMState, obj, TYPE_PIIX4_PM)

for the general public ...

Quoted 4 lines
hw/acpi/piix4.c +0 -0
@@ -458,6 +459,30 @@ static int piix4_pm_initfn(PCIDevice *dev)
     return 0;
 }
 
Quoted 11 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 470

Quoted 9 lines
hw/acpi/piix4.c +9 -0
+PIIX4PMState *piix4_pm_find(void)
+{
+    bool ambig;
+    Object *o = object_resolve_path_type("", "PIIX4_PM", &ambig);
+
+    if (ambig || !o) {
+        return NULL;
+    }
+    return OBJECT_CHECK(PIIX4PMState, o, "PIIX4_PM");

... instead of open-coding it where only you use it, please.

Quoted 8 lines

I don't really understand in which direction you want to take this. On the one hand, you are saying "there's one caller of this function so please open-code it".
On the other hand, you are saying "it does not matter that there's one user of this macro put it in the header".

Is the point that macros are somehow better than functions so they should be used where possible?

No, the point is reuse: For QOM realize we will very likely need the same thing. It was not my decision to make these macros, I'm just making Anthony's QOM pattern consistent.

Quoted 71 lines
Quoted 10 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 477

Quoted 7 lines
hw/acpi/piix4.c +7 -0
+}
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *s, AcpiPmInfo *info)
+{
+        info->s3_disabled = s->disable_s3;
+        info->s4_disabled = s->disable_s4;
+        info->s4_val = s->s4_val;

These three are accessible as qdev/QOM properties.

Quoted 7 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 482

Quoted 5 lines
hw/acpi/piix4.c +5 -0
+
+        info->acpi_enable_cmd = ACPI_ENABLE;
+        info->acpi_disable_cmd = ACPI_DISABLE;
+        info->gpe0_blk = GPE_BASE;
+        info->gpe0_blk_len = GPE_LEN;

So here the issue is that values are constant?

Yes.

Quoted 49 lines

hw/acpi/piix4.c static int piix4_pm_initfn(PCIDevice *dev) · line 483

Quoted 1 line
hw/acpi/piix4.c +1 -0
+        info->sci_int = 9;

Magic number - use a define to share it with wherever it is used?

Quoted 10 lines
hw/acpi/piix4.c +2 -0
+}
+
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
                        int kvm_enabled, FWCfgState *fw_cfg)
hw/mips/mips_malta.c +0 -0
index de87241..14573ab 100644

hw/mips/mips_malta.c void mips_malta_init(QEMUMachineInitArgs *args) · line 968

Quoted 5 lines
hw/mips/mips_malta.c +1 -1
@@ -965,7 +965,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
-                          isa_get_irq(NULL, 9), NULL, 0, NULL);
+                          isa_get_irq(NULL, 9), NULL, 0, NULL, NULL);

This looks fishy. Might belong into a different patch? Implementation didn't change above.

Quoted 8 lines
hw/mips/mips_malta.c +0 -0
     /* TODO: Populate SPD eeprom data.  */
     smbus_eeprom_init(smbus, 8, NULL, 0);
     pit = pit_init(isa_bus, 0x40, 0, NULL);
hw/pci-host/piix.c +0 -0
index 3908860..daefdfb 100644

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 8 lines
hw/pci-host/piix.c +5 -0
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

Quoted 7 lines
Quoted 3 lines

I don't mind but I would like to avoid callers hard-coding paths, in this case "i440fx".
Why the aversion to functions?

Simply because QMP cannot call functions. It has to work with qom-list and qom-get, so this is a test case showing what is missing and can IMO easily be addressed for both parties.

Fine but if the function calls QOM things internally then where's the problem?

Quoted 64 lines

The suggested cast to PCI_BUS() lets you use regular qdev functions btw as a shortcut, QMP users would need to iterate children of that node.

The suggested "pci.0" is considered stable for -device ...,bus=pci.0 according to review feedback the Xen people have received for libxl.

Andreas

Quoted 51 lines
Quoted 51 lines
Quoted 46 lines
hw/pci-host/piix.c +1 -0
+
 /* PIIX3 PCI to ISA bridge */
 static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
 {
include/hw/acpi/piix4.h new file +10 -0
new file mode 100644
index 0000000..2876428
@@ -0,0 +1,10 @@
+#ifndef HW_ACPI_PIIX4_H
+#define HW_ACPI_PIIX4_H
+
+#include "qemu/typedefs.h"
+
+PIIX4PMState *piix4_pm_find(void);
+
+void piix4_pm_get_acpi_pm_info(PIIX4PMState *, AcpiPmInfo *);
+
+#endif
include/hw/i386/pc.h +1 -0
index 7c0bd50..76af5cd 100644
@@ -186,6 +186,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn,
                     MemoryRegion *pci_memory,
                     MemoryRegion *ram_memory);
 
+PCIBus *find_i440fx(void);
 /* piix4.c */
 extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
include/qemu/typedefs.h +1 -0
index cb66e19..7d42693 100644
@@ -65,6 +65,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
+typedef struct PIIX4PMState PIIX4PMState;
 typedef struct AcpiPmInfo AcpiPmInfo;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#37 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Am 28.07.2013 12:14, schrieb Michael S. Tsirkin:

Quoted 33 lines · Andreas Färber
Quoted 32 lines

Am 28.07.2013 09:30, schrieb Michael S. Tsirkin:

Quoted 30 lines · Andreas Färber
Quoted 17 lines

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 13 lines
hw/pci-host/piix.c +5 -0
index 3908860..daefdfb 100644
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

Quoted 7 lines

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

I don't mind but I would like to avoid callers hard-coding paths, in this case "i440fx".
Why the aversion to functions?

Quoted 6 lines
Quoted 3 lines

Simply because QMP cannot call functions. It has to work with qom-list and qom-get, so this is a test case showing what is missing and can IMO easily be addressed for both parties.

Fine but if the function calls QOM things internally then where's the problem?

The grief with object_path_resolve_type() is that it's a "hack" Paolo has added for his convenience (in audio code?) that QMP cannot use, so we need name-based paths to be available.

And to clarify, I have been talking about two different time frames:
Small adjustments that you can make for 1.6 (e.g., casts, q35 property, different QOM function/callsite used; if Anthony is okay with taking ACPI at this late point) and post-1.6 cleanups to replace interim constructs that involve refactorings outside your control (e.g., MemoryRegion QOM'ification, adding properties to random devices).

Andreas

Quoted 5 lines
Quoted 5 lines

The suggested cast to PCI_BUS() lets you use regular qdev functions btw as a shortcut, QMP users would need to iterate children of that node.

The suggested "pci.0" is considered stable for -device ...,bus=pci.0 according to review feedback the Xen people have received for libxl.

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#38 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Am 28.07.2013 12:31, schrieb Andreas Färber:

Quoted 38 lines

Am 28.07.2013 12:14, schrieb Michael S. Tsirkin:

Quoted 37 lines · Andreas Färber
Quoted 35 lines

Am 28.07.2013 09:30, schrieb Michael S. Tsirkin:

Quoted 27 lines · Andreas Färber
Quoted 17 lines

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 13 lines
hw/pci-host/piix.c +5 -0
index 3908860..daefdfb 100644
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

Quoted 7 lines

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

Quoted 3 lines

I don't mind but I would like to avoid callers hard-coding paths, in this case "i440fx".
Why the aversion to functions?

Simply because QMP cannot call functions. It has to work with qom-list and qom-get, so this is a test case showing what is missing and can IMO easily be addressed for both parties.

Quoted 6 lines
Quoted 2 lines

Fine but if the function calls QOM things internally then where's the problem?

The grief with object_path_resolve_type() is that it's a "hack" Paolo has added for his convenience (in audio code?) that QMP cannot use, so we need name-based paths to be available.

Add to that, the way I see QOM devices (as opposed to qdev or pre-qdev devices) is that they are instantiated from the outside - a different source file or command line or config file - via QOM APIs, and they allow other source files to interact with them via mydev_foo(MyDev *d, ...) APIs that operate on an instance.

Having functions to create devices often hints at legacy code from pre-qdev times (we had such a discussion with Alex when I tried to qdev'ify the prep_pci device), indicating that either something is not yet accessible via qdev/QOM APIs (e.g., IRQs) or that the device is not yet implementing composition properly (e.g., creating a bus after the bridge device rather than in the bridge, or a PCIDevice after the PHB rather than by the PHB).

Having functions in the device's file to obtain a random instance of that device in the form MyDev *mydev_get(void) is what I dislike here.

My personal preference (which you may ignore if others disagree) would be to have accessors, where unavoidable, in the form:

foo mydev_get_bar(MyDev *s)

{
    return s->baz;
}

which we can then later easily convert into dynamic property getters, and it would hopefully spare us new per-device ...Info structs by obtaining the info where and when you need it.
I admit it's a bit of boilerplate to code, but I've seen at most 4 cases per device where this would apply and I'm saying this with our longer-term QOM goals in mind.

I'm skeptical towards Igor's suggestion of adding Last Minute 1.6 qdev properties (as opposed to a composition property, you force me to become very explicit in my explanations...) as that would bring ABI stability rules onto us.

Andreas

Quoted 14 lines

And to clarify, I have been talking about two different time frames:
Small adjustments that you can make for 1.6 (e.g., casts, q35 property, different QOM function/callsite used; if Anthony is okay with taking ACPI at this late point) and post-1.6 cleanups to replace interim constructs that involve refactorings outside your control (e.g., MemoryRegion QOM'ification, adding properties to random devices).

Andreas

Quoted 5 lines
Quoted 5 lines

The suggested cast to PCI_BUS() lets you use regular qdev functions btw as a shortcut, QMP users would need to iterate children of that node.

The suggested "pci.0" is considered stable for -device ...,bus=pci.0 according to review feedback the Xen people have received for libxl.

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#39 lore raw

Re: [Qemu-devel] [PATCH v3 11/14] piix: APIs for pc guest info

Quoted 60 lines · Andreas Färber

Am 28.07.2013 12:31, schrieb Andreas Färber:

Quoted 38 lines

Am 28.07.2013 12:14, schrieb Michael S. Tsirkin:

Quoted 37 lines · Andreas Färber
Quoted 35 lines

Am 28.07.2013 09:30, schrieb Michael S. Tsirkin:

Quoted 27 lines · Andreas Färber
Quoted 17 lines

Am 25.07.2013 11:32, schrieb Michael S. Tsirkin:

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 356

Quoted 13 lines
hw/pci-host/piix.c +5 -0
index 3908860..daefdfb 100644
@@ -349,6 +349,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn,
     return b;
 }
 
+PCIBus *find_i440fx(void)
+{
+    PCIHostState *s = OBJECT_CHECK(PCIHostState,
+                                   object_resolve_path("/machine/i440fx", NULL),
+                                   TYPE_PCI_HOST_BRIDGE);

Open-coded OBJECT_CHECK() - should use existing PCI_HOST_BRIDGE(...).

Quoted 7 lines

hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, · line 358

Quoted 2 lines
hw/pci-host/piix.c +2 -0
+    return s ? s->bus : NULL;
+}

Is this function really necessary? /machine/i440fx/pci.0 is a trivial addition to the path that's already being used here. You can do:
PCIBus *bus = PCI_BUS(object_resolve_path("/machine/i440fx/pci.0")); where you actually need to access it.

Quoted 3 lines

I don't mind but I would like to avoid callers hard-coding paths, in this case "i440fx".
Why the aversion to functions?

Simply because QMP cannot call functions. It has to work with qom-list and qom-get, so this is a test case showing what is missing and can IMO easily be addressed for both parties.

Quoted 6 lines
Quoted 2 lines

Fine but if the function calls QOM things internally then where's the problem?

The grief with object_path_resolve_type() is that it's a "hack" Paolo has added for his convenience (in audio code?) that QMP cannot use, so we need name-based paths to be available.

Add to that, the way I see QOM devices (as opposed to qdev or pre-qdev devices) is that they are instantiated from the outside - a different source file or command line or config file - via QOM APIs, and they allow other source files to interact with them via mydev_foo(MyDev *d, ...) APIs that operate on an instance.

Having functions to create devices often hints at legacy code from pre-qdev times (we had such a discussion with Alex when I tried to qdev'ify the prep_pci device), indicating that either something is not yet accessible via qdev/QOM APIs (e.g., IRQs) or that the device is not yet implementing composition properly (e.g., creating a bus after the bridge device rather than in the bridge, or a PCIDevice after the PHB rather than by the PHB).

Quoted 2 lines

Having functions in the device's file to obtain a random instance of that device in the form MyDev *mydev_get(void) is what I dislike here.

Absolutely but what would you do?
E.g. we can't handle more than one instance of PIIX ATM.

Quoted 7 lines

My personal preference (which you may ignore if others disagree) would be to have accessors, where unavoidable, in the form:

foo mydev_get_bar(MyDev *s)

{
    return s->baz;
}

So how about
implementing mydev_get_bar(void) and make that do the lookup internally using a path?
Also mydev_present to test that.

Quoted 33 lines

which we can then later easily convert into dynamic property getters, and it would hopefully spare us new per-device ...Info structs by obtaining the info where and when you need it.
I admit it's a bit of boilerplate to code, but I've seen at most 4 cases per device where this would apply and I'm saying this with our longer-term QOM goals in mind.

I'm skeptical towards Igor's suggestion of adding Last Minute 1.6 qdev properties (as opposed to a composition property, you force me to become very explicit in my explanations...) as that would bring ABI stability rules onto us.

Andreas

Quoted 14 lines

And to clarify, I have been talking about two different time frames:
Small adjustments that you can make for 1.6 (e.g., casts, q35 property, different QOM function/callsite used; if Anthony is okay with taking ACPI at this late point) and post-1.6 cleanups to replace interim constructs that involve refactorings outside your control (e.g., MemoryRegion QOM'ification, adding properties to random devices).

Andreas

Quoted 5 lines
Quoted 5 lines

The suggested cast to PCI_BUS() lets you use regular qdev functions btw as a shortcut, QMP users would need to iterate children of that node.

The suggested "pci.0" is considered stable for -device ...,bus=pci.0 according to review feedback the Xen people have received for libxl.

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#41 lore raw

PATCH v3 12/14 pvpanic: add API to access io port

In reply to Michael S. Tsirkin

Add API to find pvpanic device and get its io port. Will be used to fill in guest info structure.

---
 hw/misc/pvpanic.c    | 11 +++++++++++
 include/hw/i386/pc.h |  1 +
 2 files changed, 12 insertions(+)
hw/misc/pvpanic.c +11 -0
index 7bb49a5..bb403e9 100644
@@ -122,6 +122,17 @@ void pvpanic_init(ISABus *bus)
     pvpanic_fw_cfg(dev, fw_cfg);
 }
 
+uint16_t pvpanic_port(void)
+{
+    Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, NULL);
+    PVPanicState *s;
+    if (!o) {
+        return 0;
+    }
+    s = ISA_PVPANIC_DEVICE(o);
+    return s->ioport;
+}
+
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16("ioport", PVPanicState, ioport, 0x505),
     DEFINE_PROP_END_OF_LIST(),
include/hw/i386/pc.h +1 -0
index 76af5cd..e718a59 100644
@@ -228,6 +228,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);
 
 /* pvpanic.c */
 void pvpanic_init(ISABus *bus);
+uint16_t pvpanic_port(void);
 
 /* e820 types */
 #define E820_RAM        1
Signature · 1 line
MST
#42 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

hw/misc/pvpanic.c void pvpanic_init(ISABus *bus) · line 131

Quoted 10 lines · Michael S. Tsirkin

Add API to find pvpanic device and get its io port. Will be used to fill in guest info structure.

hw/misc/pvpanic.c +7 -0
+uint16_t pvpanic_port(void)
+{
+    Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, NULL);
+    PVPanicState *s;
+    if (!o) {
+        return 0;
+    }
       return object_property_get_int(o, "ioport");
}

Then you don't need PVPanicState access and can place the code into acpi-build.c.

cheers,
Gerd

#43 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

Quoted 15 lines · Gerd Hoffmann

hw/misc/pvpanic.c void pvpanic_init(ISABus *bus) · line 131

Quoted 10 lines · Michael S. Tsirkin

Add API to find pvpanic device and get its io port. Will be used to fill in guest info structure.

hw/misc/pvpanic.c +7 -0
+uint16_t pvpanic_port(void)
+{
+    Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, NULL);
+    PVPanicState *s;
+    if (!o) {
+        return 0;
+    }
       return object_property_get_int(o, "ioport");
}
Quoted 5 lines

Then you don't need PVPanicState access and can place the code into acpi-build.c.

cheers,
Gerd

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics, or make
a mistake in acpi-build.c
Same applies to TYPE_ISA_PVPANIC_DEVICE: better to expose an API than expose the type externally.

Signature · 1 line
MST
#44 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Gerd Hoffmann

hw/misc/pvpanic.c void pvpanic_init(ISABus *bus) · line 131

Quoted 10 lines · Michael S. Tsirkin

Add API to find pvpanic device and get its io port. Will be used to fill in guest info structure.

hw/misc/pvpanic.c +7 -0
+uint16_t pvpanic_port(void)
+{
+    Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, NULL);
+    PVPanicState *s;
+    if (!o) {
+        return 0;
+    }
       return object_property_get_int(o, "ioport");
}

Then you don't need PVPanicState access and can place the code into acpi-build.c.

Quoted 8 lines
Quoted 2 lines

cheers,
Gerd

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics, or make
a mistake in acpi-build.c

And even within pvpanic.c, this will make me copy-paste the "ioport" string or create yet another macro.

    s = ISA_PVPANIC_DEVICE(o);
    return s->ioport;

seems nicer.

Quoted 7 lines

Same applies to TYPE_ISA_PVPANIC_DEVICE: better to expose an API than expose the type externally.

Signature · 1 line
MST
#45 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

In reply to Michael S. Tsirkin

Hi,

Quoted 4 lines

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics,

I'm not worried. Changing the strings will break the command line interface too (qemu -device pvpanic,ioport=...), so that isn't going to happen.

cheers,
Gerd

#46 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

Quoted 7 lines · Gerd Hoffmann

Hi,

Quoted 4 lines

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics,

Quoted 6 lines

I'm not worried. Changing the strings will break the command line interface too (qemu -device pvpanic,ioport=...), so that isn't going to happen.

cheers,
Gerd

What will catch this breakage?
There are 0 users actually tweaking the port number so I'm sure no one will notice this.

In any case, catching errors at compile time is much better than at runtime.

What exactly are advantages of duplicating property names in this way? I don't see any.

Signature · 1 line
MST
#47 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

Quoted 19 lines · Michael S. Tsirkin
Quoted 7 lines · Gerd Hoffmann

Hi,

Quoted 4 lines

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics,

Quoted 6 lines

I'm not worried. Changing the strings will break the command line interface too (qemu -device pvpanic,ioport=...), so that isn't going to happen.

cheers,
Gerd

What will catch this breakage?
There are 0 users actually tweaking the port number so I'm sure no one will notice this.

Quoted 5 lines

In any case, catching errors at compile time is much better than at runtime.

What exactly are advantages of duplicating property names in this way? I don't see any.

You don't need access to pvpanic internals then and thus the code can be moved over to the acpi generator. At least in this case where all info needed is already available via properties.

cheers,
Gerd

#48 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

Quoted 26 lines · Gerd Hoffmann
Quoted 19 lines · Michael S. Tsirkin
Quoted 7 lines · Gerd Hoffmann

Hi,

Quoted 4 lines

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics,

Quoted 6 lines

I'm not worried. Changing the strings will break the command line interface too (qemu -device pvpanic,ioport=...), so that isn't going to happen.

cheers,
Gerd

What will catch this breakage?
There are 0 users actually tweaking the port number so I'm sure no one will notice this.

Quoted 5 lines

In any case, catching errors at compile time is much better than at runtime.

What exactly are advantages of duplicating property names in this way? I don't see any.

Quoted 6 lines

You don't need access to pvpanic internals then and thus the code can be moved over to the acpi generator. At least in this case where all info needed is already available via properties.

cheers,
Gerd

We'll have to disagree here.
There's no access to internals with an API.
I prefer using APIs, since they are compiler-checked.

Signature · 1 line
MST
#49 lore raw

Re: [Qemu-devel] [PATCH v3 12/14] pvpanic: add API to access io port

Am 25.07.2013 14:23, schrieb Michael S. Tsirkin:

Quoted 22 lines · Gerd Hoffmann
Quoted 21 lines · Michael S. Tsirkin
Quoted 19 lines · Gerd Hoffmann
Quoted 8 lines
Quoted 4 lines

I can change the implementation but I don't think it's a good idea to copy property names around:
it's too fragile, compiler won't warn us if we change the name or value semantics,

I'm not worried. Changing the strings will break the command line interface too (qemu -device pvpanic,ioport=...), so that isn't going to happen.

What will catch this breakage?
There are 0 users actually tweaking the port number so I'm sure no one will notice this.

In any case, catching errors at compile time is much better than at runtime.

What exactly are advantages of duplicating property names in this way? I don't see any.

Quoted 7 lines
Quoted 3 lines

You don't need access to pvpanic internals then and thus the code can be moved over to the acpi generator. At least in this case where all info needed is already available via properties.

We'll have to disagree here.
There's no access to internals with an API.
I prefer using APIs, since they are compiler-checked.

Sorry, I don't understand, is there a typo? A qdev "ioport" property is hardly internal, and QOM has an API to access it.

For QOM properties we have ABI stability rules in place, not only for the textual command line: No one is allowed to change the type of a property in an incompatible way. And dropping it would be a command-line-incompatible change in this case. Properties don't magically disappear at runtime, and since you're writing this code you can rely on the property being present and the person attempting to remove it noticing it while testing.

You're writing redundant code here, and it's not your device IIRC.

I vaguely remember seeing you or Xen guys adding some check that the pvpanic device can only be instantiated once, right? In that case I would consider it best to add an object_property_add_child(qdev_get_machine(), "pvpanic", foo, NULL); call into pvpanic device creation, then you can access it from ACPI code without needing to know the type via

obj = object_path_resolve_component(qdev_get_machine(), "pvpanic");

if (obj != NULL) {
    val = object_property_get_int(obj, "ioport", &err);
    assert_no_error(&err);
}

and pvpanic code remains untouched.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#50 lore raw

PATCH v3 13/14 hpet: add API to find it

In reply to Michael S. Tsirkin

Add API to find HPET using QOM.

---
 hw/timer/hpet.c         | 5 +++++
 include/hw/timer/hpet.h | 2 ++
 2 files changed, 7 insertions(+)
hw/timer/hpet.c +5 -0
index 648b383..11bf401 100644
@@ -757,6 +757,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     dc->props = hpet_device_properties;
 }
 
+bool hpet_find(void)
+{
+    return object_resolve_path_type("", "hpet", NULL);
+}
+
 static const TypeInfo hpet_device_info = {
     .name          = TYPE_HPET,
     .parent        = TYPE_SYS_BUS_DEVICE,
include/hw/timer/hpet.h +2 -0
index 757f79f..ab44bd3 100644
@@ -71,4 +71,6 @@ struct hpet_fw_config
 } QEMU_PACKED;
 
 extern struct hpet_fw_config hpet_cfg;
+
+bool hpet_find(void);
 #endif
Signature · 1 line
MST
#51 lore raw

Re: [Qemu-devel] [PATCH v3 13/14] hpet: add API to find it

Quoted 1 line · Michael S. Tsirkin

+bool hpet_find(void)

given this returns just a bool hpet_present() would be a better name I think.

cheers,
Gerd

#52 lore raw

Re: [Qemu-devel] [PATCH v3 13/14] hpet: add API to find it

In reply to Michael S. Tsirkin

Am 24.07.2013 18:02, schrieb Michael S. Tsirkin:

Quoted 14 lines

Add API to find HPET using QOM.

---
 hw/timer/hpet.c         | 5 +++++
 include/hw/timer/hpet.h | 2 ++
 2 files changed, 7 insertions(+)
hw/timer/hpet.c +0 -0
index 648b383..11bf401 100644
@@ -757,6 +757,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     dc->props = hpet_device_properties;

hw/timer/hpet.c static void hpet_device_class_init(ObjectClass *klass, void *data) · line 767

Quoted 10 lines
hw/timer/hpet.c +5 -0
 }
 
+bool hpet_find(void)
+{
+    return object_resolve_path_type("", "hpet", NULL);
+}
+
 static const TypeInfo hpet_device_info = {
     .name          = TYPE_HPET,
     .parent        = TYPE_SYS_BUS_DEVICE,

"hpet" is being open-coded just above the new TYPE_HPET.

http://git.qemu.org/?p=qemu.git;a=commit;h=02f9a6f5da74251e1e5685ae57643d45c3fb6c30

But since you're doing it and the code is really trivial, you could also inline it into ACPI code to spare us this single-use function.

include/hw/timer/hpet.h struct hpet_fw_config · line 76

Quoted 11 lines
include/hw/timer/hpet.h +2 -0
index 757f79f..ab44bd3 100644
@@ -71,4 +71,6 @@ struct hpet_fw_config
 } QEMU_PACKED;
 
 extern struct hpet_fw_config hpet_cfg;
+
+bool hpet_find(void);
 #endif

We could just as well move TYPE_HPET here to allow reuse from ACPI code. Not having done above conversion patch myself, I did not notice there was a header candidate.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#53 lore raw

PATCH v3 14/14 i386: ACPI table generation code from seabios

In reply to Michael S. Tsirkin

This adds C code for generating ACPI tables at runtime, imported from seabios git tree

    commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd

Although ACPI tables come from a system BIOS on real hw, it makes sense that the ACPI tables are coupled with the virtual machine, since they have to abstract the x86 machine to the OS's.

This is widely desired as a way to avoid the churn and proliferation of QEMU-specific interfaces associated with ACPI tables in bios code.

Notes:
The code structure was intentionally kept as close to the seabios original as possible, to simplify comparison and making sure we didn't lose anything in translation.

Minor code duplication results, to help ensure there are no functional regressions, I think it's better to merge it like this and do more code changes in follow-up patches.

Cross-version compatibility concerns have been addressed:
ACPI tables are exposed to guest as FW_CFG entries. When running with -M 1.5 and older, this patch disables ACPI table generation, and doesn't expose ACPI
tables to guest.

As table content is likely to change over time,
the following measures are taken to simplify
cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry. This entry size is currently 23K. We round it up to 64K to avoid too much churn there.
- Tables are placed in special ROM blob (not mapped into guest memory) which is automatically migrated together with the guest, same as BIOS code.

This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.

Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:

src/acpi-dsdt-cpu-hotplug.dsl
src/acpi-dsdt-dbug.dsl
src/acpi-dsdt-hpet.dsl
src/acpi-dsdt-isa.dsl
src/acpi-dsdt-pci-crs.dsl
src/acpi.c
src/acpi.h
src/ssdt-misc.dsl
src/ssdt-pcihp.dsl
src/ssdt-proc.dsl
tools/acpi_extract.py
tools/acpi_extract_preprocess.py

Each one of the listed people agreed to the following:

Quoted 5 lines

If you allow the use of your contribution in QEMU under the terms of GPLv2 or later as proposed by this patch, please respond to this mail including the line:

Acked-by Name <email address>
---
 hw/i386/Makefile.objs        |   4 +
 hw/i386/acpi-build.c         | 907 +++++++++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-defs.h          | 327 ++++++++++++++++
 hw/i386/pc.c                 |   2 +
 hw/i386/pc_piix.c            |   5 +
 hw/i386/pc_q35.c             |   3 +
 include/hw/i386/acpi-build.h |   9 +
 include/hw/i386/pc.h         |   1 +
 8 files changed, 1258 insertions(+)
 create mode 100644 hw/i386/acpi-build.c
 create mode 100644 hw/i386/acpi-defs.h
 create mode 100644 include/hw/i386/acpi-build.h
hw/i386/Makefile.objs +4 -0
index 71be2da..6754fd5 100644
@@ -4,7 +4,11 @@ obj-y += pc.o pc_piix.o pc_q35.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 obj-y += kvmvapic.o
+obj-y += acpi-build.o
 obj-y += bios-linker-loader.o
+hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \
+	hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \
+	hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex
 
 iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
     ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c new file +907 -0

907 lines not on this page · raw message

hw/i386/acpi-defs.h new file +327 -0

327 lines not on this page · raw message

hw/i386/pc.c +2 -0
index b9b8f92..edd49e5 100644
@@ -55,6 +55,7 @@
 #include "hw/acpi/acpi.h"
 #include "hw/cpu/icc_bus.h"
 #include "hw/boards.h"
+#include "hw/i386/acpi-build.h"
 
 /* debug PC/ISA interrupts */
 //#define DEBUG_IRQ
@@ -1050,6 +1051,7 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)
                                                       PcGuestInfoState,
                                                       machine_done);
     pc_fw_cfg_guest_info(&guest_info_state->info);
+    acpi_setup(&guest_info_state->info);
 }
 
 PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
hw/i386/pc_piix.c +5 -0
index b58c255..f365e6e 100644
@@ -58,6 +58,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 static bool has_pvpanic = true;
 static bool has_pci_info = true;
+static bool has_acpi_build = true;
 
 /* PC hardware initialisation */
 static void pc_init1(MemoryRegion *system_memory,
@@ -127,6 +128,9 @@ static void pc_init1(MemoryRegion *system_memory,
     }
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
+
+    guest_info->has_acpi_build = has_acpi_build;
+
     guest_info->has_pci_info = has_pci_info;
 
     /* Set PCI window size the way seabios has always done it. */
@@ -264,6 +268,7 @@ static void pc_init_pci(QEMUMachineInitArgs *args)
 static void pc_init_pci_1_5(QEMUMachineInitArgs *args)
 {
     has_pci_info = false;
+    has_acpi_build = false;
     pc_init_pci(args);
 }
 
hw/i386/pc_q35.c +3 -0
index 0b1d2e3..0edd408 100644
@@ -48,6 +48,7 @@
 
 static bool has_pvpanic = true;
 static bool has_pci_info = true;
+static bool has_acpi_build = true;
 
 /* PC hardware initialisation */
 static void pc_q35_init(QEMUMachineInitArgs *args)
@@ -110,6 +111,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
     guest_info->has_pci_info = has_pci_info;
+    guest_info->has_acpi_build = has_acpi_build;
 
     /* allocate ram and load rom/bios */
     if (!xen_enabled()) {
@@ -219,6 +221,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
 static void pc_q35_init_1_5(QEMUMachineInitArgs *args)
 {
     has_pci_info = false;
+    has_acpi_build = false;
     pc_q35_init(args);
 }
 
include/hw/i386/acpi-build.h new file +9 -0
new file mode 100644
index 0000000..e57b1aa
@@ -0,0 +1,9 @@
+
+#ifndef HW_I386_ACPI_BUILD_H
+#define HW_I386_ACPI_BUILD_H
+
+#include "qemu/typedefs.h"
+
+void acpi_setup(PcGuestInfo *);
+
+#endif
include/hw/i386/pc.h +1 -0
index e718a59..0020332 100644
@@ -52,6 +52,7 @@ struct PcGuestInfo {
     unsigned dsdt_size;
     uint16_t pvpanic_port;
     FWCfgState *fw_cfg;
+    bool has_acpi_build;
 };
 
 /* parallel.c */
Signature · 1 line
MST
#54 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Hi,

Quoted 6 lines

As table content is likely to change over time,
the following measures are taken to simplify cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry. This entry size is currently 23K. We round it up to 64K to avoid too much churn there.

Does it need to be that way? I'd prefer to have one fw_cfg entry per table.

cheers,
Gerd

#55 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 6 lines

As table content is likely to change over time,
the following measures are taken to simplify cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry. This entry size is currently 23K. We round it up to 64K to avoid too much churn there.

Quoted 5 lines

Does it need to be that way? I'd prefer to have one fw_cfg entry per table.

cheers,
Gerd

It's better I think. The advantages are:
- when we add more tables we don't break cross-version migration compatibility
- we have limited number of files, this way we won't run out of them

what are advantages of file per table?

#56 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Gerd Hoffmann

Hi,

Quoted 6 lines

As table content is likely to change over time,
the following measures are taken to simplify cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry. This entry size is currently 23K. We round it up to 64K to avoid too much churn there.

Does it need to be that way? I'd prefer to have one fw_cfg entry per table.

Quoted 7 lines
Quoted 3 lines

cheers,
Gerd

It's better I think. The advantages are:
- when we add more tables we don't break cross-version migration compatibility

New tables are a guest-visible change, so I think we have to turn them off for old machine types via compat properties anyway. This will also solve the migration issue.

Quoted 2 lines

- we have limited number of files, this way we won't run out of them

Anything which prevents us from raising that number?

Quoted 1 line

what are advantages of file per table?

You can look at the tables without doing a full linker pass first, so the firmware can easily initialize the hardware according to what it finds in specific acpi tables. Check FADT for pm_base. Check MCFG for mmconf xbar location.

cheers,
Gerd

#57 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Quoted 17 lines · Gerd Hoffmann
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Gerd Hoffmann

Hi,

Quoted 6 lines

As table content is likely to change over time,
the following measures are taken to simplify cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry. This entry size is currently 23K. We round it up to 64K to avoid too much churn there.

Does it need to be that way? I'd prefer to have one fw_cfg entry per table.

cheers,
Gerd

Quoted 7 lines
Quoted 3 lines

It's better I think. The advantages are:
- when we add more tables we don't break cross-version migration compatibility

New tables are a guest-visible change, so I think we have to turn them off for old machine types via compat properties anyway. This will also solve the migration issue.

ACPI is really part of bios.
We *do* make guest visible changes to bios rom, so I'm not so sure we should take a hard-line stance on this.

Quoted 4 lines
Quoted 2 lines

- we have limited number of files, this way we won't run out of them

Anything which prevents us from raising that number?

There's a static array so we can extend it a bit,
but making it large and dynamic is hard.

I *really* want to keep the number of moving parts to minimum, this is a huge patchset as it is.

So please, let's keep it simple, and have everything in one file, and we can move things around later any number of times if/when the need arises.

Quoted 9 lines
Quoted 1 line

what are advantages of file per table?

You can look at the tables without doing a full linker pass first, so the firmware can easily initialize the hardware according to what it finds in specific acpi tables. Check FADT for pm_base. Check MCFG for mmconf xbar location.

cheers,
Gerd

That's something I think that it's best for firmware to avoid. Much better to load tables in memory and use standard ACPI methods to find specific tables.

It's a general thing: paravirtualization is often easier but let's use standard interfaces where possible.

Sticking everything in one file will serve to keep firmware honest and not let it cut corners.

Signature · 1 line
MST
#58 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Hi,

Quoted 11 lines
Quoted 7 lines

You can look at the tables without doing a full linker pass first, so the firmware can easily initialize the hardware according to what it finds in specific acpi tables. Check FADT for pm_base. Check MCFG for mmconf xbar location.

cheers,
Gerd

That's something I think that it's best for firmware to avoid. Much better to load tables in memory and use standard ACPI methods to find specific tables.

Problem is this happens relatively late in the firmware boot process.

Quoted 2 lines

It's a general thing: paravirtualization is often easier but let's use standard interfaces where possible.

Sure. Thats why I want read the info from the acpi tables. Being able to do that without a full acpi table linker pass makes this easier for the firmware, especially for informations needed very early in the initialization process.

What is wrong with etc/acpi/fadt ?

Quoted 2 lines

Sticking everything in one file will serve to keep firmware honest and not let it cut corners.

Parse error.

cheers,
Gerd

#59 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Hi,

Quoted 5 lines
Quoted 3 lines

That's something I think that it's best for firmware to avoid. Much better to load tables in memory and use standard ACPI methods to find specific tables.

Problem is this happens relatively late in the firmware boot process.

Completely different idea to tackle the issue: use COMMAND_ADD_POINTER not only for table pointers, but also register offsets. So the firmware doesn't need to parse fadt to figure how it should program pm_base, but instead can fixup the fadt according to the pm_base it has used.

That is more in line with how firmware works (pm_base and simliar things tends to be #defines and are not runtime-configurable). And I think it's also more robust when extending/changing tables for newer acpi spec revisions.

cheers,
Gerd

#60 lore raw

Re: [Qemu-devel] [PATCH v3 14/14] i386: ACPI table generation code from seabios

Quoted 13 lines · Gerd Hoffmann

Hi,

Quoted 5 lines
Quoted 3 lines

That's something I think that it's best for firmware to avoid. Much better to load tables in memory and use standard ACPI methods to find specific tables.

Problem is this happens relatively late in the firmware boot process.

Completely different idea to tackle the issue: use COMMAND_ADD_POINTER not only for table pointers, but also register offsets. So the firmware doesn't need to parse fadt to figure how it should program pm_base, but instead can fixup the fadt according to the pm_base it has used.

Quoted 8 lines

That is more in line with how firmware works (pm_base and simliar things tends to be #defines and are not runtime-configurable). And I think it's also more robust when extending/changing tables for newer acpi spec revisions.

cheers,
Gerd

And for newer chipsets. I agree. I plan to add a file to configure how firmware programs PCI devices at init.

Signature · 1 line
MST
#61 lore raw
In reply to Michael S. Tsirkin

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

I believe Anthony asked to extract the information from the QOM tree, originally from the SeaBIOS side, then later agreeing to do it on the QEMU side.

However here I am still seeing *functions* added in device code to check device existence and to extract individual fields. I was assuming (and clearly prefer) such code to live in a central place, be it acpi-build.c or something else, and to use QOM *API*s to obtain information when needed rather than building up lots of new structs duplicating that data. That would at the same time be a test case for how useful the QOM tree is

I'm not sure if there was a misunderstanding or whether the PC QOM model still sucks^W is incomplete? Anthony and Ping Fang(?) had both posted patches to improve the composition tree once. If there's properties missing that you need to access for ACPI, we should simply add them.

For i440fx we have /machine/i440fx.
For q35 I encountered an mch child on q35-pcihost, but what's trivially missing apparently is to add q35-pcihost as a child to /machine, e.g. /machine/q35.
Then you'll end up doing
Object *obj = object_resolve_path_component(qdev_get_machine(), "q35/mch"); object_property_get_int(obj, "foo", &err); object_property_get_string(obj, "bar", &err);
and so on. No need to do the TYPE_... based search for everything.

User-added -devices will show up in /machine/peripheral or /machine/peripheral-anon depending on whether id= is used, so there a type-based search probably makes sense. And there is nothing wrong with moving the TYPE_* constants to a device header where not yet the case, to allow that from generic code.

Similarly, please don't open-code OBJECT_CHECK()s, do a trivial patch with a macro that we can then reuse elsewhere. I'd be happy to review such QOM patches and help fast-track them into master.

Will take a closer look at the implementation later.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#62 lore raw
Quoted 41 lines · Andreas Färber

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

I believe Anthony asked to extract the information from the QOM tree, originally from the SeaBIOS side, then later agreeing to do it on the QEMU side.

However here I am still seeing *functions* added in device code to check device existence and to extract individual fields. I was assuming (and clearly prefer) such code to live in a central place, be it acpi-build.c or something else, and to use QOM *API*s to obtain information when needed rather than building up lots of new structs duplicating that data. That would at the same time be a test case for how useful the QOM tree is

I'm not sure if there was a misunderstanding or whether the PC QOM model still sucks^W is incomplete? Anthony and Ping Fang(?) had both posted patches to improve the composition tree once. If there's properties missing that you need to access for ACPI, we should simply add them. For i440fx we have /machine/i440fx.
For q35 I encountered an mch child on q35-pcihost, but what's trivially missing apparently is to add q35-pcihost as a child to /machine, e.g. /machine/q35.
Then you'll end up doing
Object *obj = object_resolve_path_component(qdev_get_machine(), "q35/mch"); object_property_get_int(obj, "foo", &err); object_property_get_string(obj, "bar", &err);
and so on. No need to do the TYPE_... based search for everything.

User-added -devices will show up in /machine/peripheral or /machine/peripheral-anon depending on whether id= is used, so there a type-based search probably makes sense. And there is nothing wrong with moving the TYPE_* constants to a device header where not yet the case, to allow that from generic code.

Quoted 9 lines

Similarly, please don't open-code OBJECT_CHECK()s, do a trivial patch with a macro that we can then reuse elsewhere. I'd be happy to review such QOM patches and help fast-track them into master.

Will take a closer look at the implementation later.

Regards,
Andreas

This is not my understanding of previous comments on list or on KVM call.

Basically it sounds like you want to make my work depend on completion of QOM conversion.
I think we explicitly agreed full QOM convertion is not a blocker.

Meanwhile, I'm adding APIs in particular so you can work on converting things to QOM without bothering with ACPI. If you want to know what is missing, you only need to look at the patches themselves, once they are merged you can rework them internally without need to touch acpi code.

As for your suggestion to poke at internal structures in a central place - generally, I don't see why poking at internal field or properties of all kind of device structures or hard-coding paths in acpi-build is a good idea, surely accessing structures through APIs is the basic idea of data hiding.

Using QOM to find devices rather than passing pointers around makes sense to me since this removes the need to depend on initialization order.

Quoted 3 lines
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#63 lore raw

Am 25.07.2013 18:19, schrieb Michael S. Tsirkin:

Quoted 46 lines · Andreas Färber
Quoted 45 lines

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

I believe Anthony asked to extract the information from the QOM tree, originally from the SeaBIOS side, then later agreeing to do it on the QEMU side.

However here I am still seeing *functions* added in device code to check device existence and to extract individual fields. I was assuming (and clearly prefer) such code to live in a central place, be it acpi-build.c or something else, and to use QOM *API*s to obtain information when needed rather than building up lots of new structs duplicating that data. That would at the same time be a test case for how useful the QOM tree is

I'm not sure if there was a misunderstanding or whether the PC QOM model still sucks^W is incomplete? Anthony and Ping Fang(?) had both posted patches to improve the composition tree once. If there's properties missing that you need to access for ACPI, we should simply add them. For i440fx we have /machine/i440fx.
For q35 I encountered an mch child on q35-pcihost, but what's trivially missing apparently is to add q35-pcihost as a child to /machine, e.g. /machine/q35.
Then you'll end up doing
Object *obj = object_resolve_path_component(qdev_get_machine(), "q35/mch"); object_property_get_int(obj, "foo", &err); object_property_get_string(obj, "bar", &err);
and so on. No need to do the TYPE_... based search for everything.

User-added -devices will show up in /machine/peripheral or /machine/peripheral-anon depending on whether id= is used, so there a type-based search probably makes sense. And there is nothing wrong with moving the TYPE_* constants to a device header where not yet the case, to allow that from generic code.

Similarly, please don't open-code OBJECT_CHECK()s, do a trivial patch with a macro that we can then reuse elsewhere. I'd be happy to review such QOM patches and help fast-track them into master.

Quoted 8 lines
Quoted 1 line

Will take a closer look at the implementation later.

This is not my understanding of previous comments on list or on KVM call.

Basically it sounds like you want to make my work depend on completion of QOM conversion.
I think we explicitly agreed full QOM convertion is not a blocker.

Not sure what you mean with "completion of QOM conversion" or "full QOM conversion". What I am saying is that instead of spending time adding functions to devices that fulfill your own ACPI needs only, that time were better spent adding QOM properties where not yet existent.

Because then what you can access for ACPI can also be accessed by libvirt and other management tools as well as qtest - I consider it a test case. QMP does not offer an instance/path search by type.

Quoted 4 lines

Meanwhile, I'm adding APIs in particular so you can work on converting things to QOM without bothering with ACPI. If you want to know what is missing, you only need to look at the patches themselves, once they are merged you can rework them internally without need to touch acpi code.

I do intend to look at them but did not have time yesterday.

I brought up my comments early because Hard Freeze is approaching fast and I fear that if your v3 series is applied to 1.6 and is working, you will not bother to send follow-up fixes after 1.6 anymore because you do not care about whether that code is considered bad design by others, and thus things will likely stay in a bad shape. You cannot expect me to do everything (not to mention that it was Anthony's idea in the first place).

Quoted 1 line

As for your suggestion to poke at internal structures in a central place -

I never suggested that, on the contrary. See my example above using
Object: There is no need to even expose structs to ACPI to access things via QOM properties.

Regards,
Andreas

Quoted 8 lines

generally, I don't see why poking at internal field or properties of all kind of device structures or hard-coding paths in acpi-build is a good idea, surely accessing structures through APIs is the basic idea of data hiding.

Using QOM to find devices rather than passing pointers around makes sense to me since this removes the need to depend on initialization order.

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#64 lore raw

Am 26.07.2013 14:19, schrieb Andreas Färber:

Quoted 56 lines

Am 25.07.2013 18:19, schrieb Michael S. Tsirkin:

Quoted 46 lines · Andreas Färber
Quoted 45 lines

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

I believe Anthony asked to extract the information from the QOM tree, originally from the SeaBIOS side, then later agreeing to do it on the QEMU side.

However here I am still seeing *functions* added in device code to check device existence and to extract individual fields. I was assuming (and clearly prefer) such code to live in a central place, be it acpi-build.c or something else, and to use QOM *API*s to obtain information when needed rather than building up lots of new structs duplicating that data. That would at the same time be a test case for how useful the QOM tree is

I'm not sure if there was a misunderstanding or whether the PC QOM model still sucks^W is incomplete? Anthony and Ping Fang(?) had both posted patches to improve the composition tree once. If there's properties missing that you need to access for ACPI, we should simply add them. For i440fx we have /machine/i440fx.
For q35 I encountered an mch child on q35-pcihost, but what's trivially missing apparently is to add q35-pcihost as a child to /machine, e.g. /machine/q35.
Then you'll end up doing
Object *obj = object_resolve_path_component(qdev_get_machine(), "q35/mch"); object_property_get_int(obj, "foo", &err); object_property_get_string(obj, "bar", &err);
and so on. No need to do the TYPE_... based search for everything.

User-added -devices will show up in /machine/peripheral or /machine/peripheral-anon depending on whether id= is used, so there a type-based search probably makes sense. And there is nothing wrong with moving the TYPE_* constants to a device header where not yet the case, to allow that from generic code.

Similarly, please don't open-code OBJECT_CHECK()s, do a trivial patch with a macro that we can then reuse elsewhere. I'd be happy to review such QOM patches and help fast-track them into master.

Quoted 8 lines
Quoted 1 line

Will take a closer look at the implementation later.

This is not my understanding of previous comments on list or on KVM call.

Basically it sounds like you want to make my work depend on completion of QOM conversion.
I think we explicitly agreed full QOM convertion is not a blocker.

Quoted 8 lines

Not sure what you mean with "completion of QOM conversion" or "full QOM conversion". What I am saying is that instead of spending time adding functions to devices that fulfill your own ACPI needs only, that time were better spent adding QOM properties where not yet existent.

Because then what you can access for ACPI can also be accessed by libvirt and other management tools as well as qtest - I consider it a test case. QMP does not offer an instance/path search by type.

To clarify for everyone what we're talking about here, I'm attaching /machine composition tree dumps for pc,accel=kvm and q35,accel=kvm plus the rudimentary script I used to generate it.

It shows for instance the mentioned /machine/i440fx and lack of /machine/q35. It also shows that there would be a /machine/fw_cfg.

Paths starting with /machine/unassigned shouldn't be hardcoded anywhere (that's the nobody-added-it-as-a-child<> bucket), except maybe for /machine/unassigned/sysbus. But whenever there's a link from a named device to a /machine/unassigned/device[n] that may of course be used dynamically, e.g. /machine/icc-bridge/icc to discover CPUs and APICs.

HTH,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

/machine
type: container

/machine/i440fx
parent_bus: /machine/unattached/sysbus
realized: True
type: i440FX-pcihost

/machine/i440fx/ioapic
parent_bus: /machine/unattached/sysbus
gsi_base: 0
realized: True
type: kvm-ioapic

/machine/i440fx/pci.0
child[5]: /machine/unattached/device[23]
child[4]: /machine/unattached/device[21]
child[3]: /machine/unattached/device[20]
child[2]: /machine/unattached/device[8]
child[1]: /machine/unattached/device[5]
child[0]: /machine/unattached/device[4]
type: PCI

/machine/fw_cfg
parent_bus: /machine/unattached/sysbus
data_iobase: 1297
legacy-data_iobase: 0x511
ctl_iobase: 1296
legacy-ctl_iobase: 0x510
realized: True
type: fw_cfg

/machine/icc-bridge
parent_bus: /machine/unattached/sysbus
realized: True
type: icc-bridge

/machine/icc-bridge/icc
child[1]: /machine/unattached/device[0]/apic
child[0]: /machine/unattached/device[0]
type: icc-bus

/machine/unattached
type: container

/machine/unattached/device[32]
parent_bus: /machine/unattached/device[5]/isa.0
ioport: 1285
realized: True
type: pvpanic

/machine/unattached/device[31]
parent_bus: /machine/unattached/device[23]/i2c
address: 87
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[30]
parent_bus: /machine/unattached/device[23]/i2c
address: 86
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[29]
parent_bus: /machine/unattached/device[23]/i2c
address: 85
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[28]
parent_bus: /machine/unattached/device[23]/i2c
address: 84
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[27]
parent_bus: /machine/unattached/device[23]/i2c
address: 83
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[26]
parent_bus: /machine/unattached/device[23]/i2c
address: 82
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[25]
parent_bus: /machine/unattached/device[23]/i2c
address: 81
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[24]
parent_bus: /machine/unattached/device[23]/i2c
address: 80
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[23]
parent_bus: /machine/i440fx/pci.0
command_serr_enable: True
legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile:
legacy-romfile: <null>
addr: 11
legacy-addr: 01.3
s4_val: 2
disable_s4: 0
disable_s3: 0
smb_io_base: 45312
realized: True
type: PIIX4_PM

/machine/unattached/device[23]/i2c
child[7]: /machine/unattached/device[31]
child[6]: /machine/unattached/device[30]
child[5]: /machine/unattached/device[29]
child[4]: /machine/unattached/device[28]
child[3]: /machine/unattached/device[27]
child[2]: /machine/unattached/device[26]
child[1]: /machine/unattached/device[25]
child[0]: /machine/unattached/device[24]
type: i2c-bus

/machine/unattached/device[22]
parent_bus: /machine/unattached/device[21]/ide.1
unit: 0
model:
legacy-model: <null>
serial: QM00003
legacy-serial: "QM00003"
wwn: 0
legacy-wwn: 0x0
ver: 1.5.50
legacy-ver: "1.5.50"
discard_granularity: 512
bootindex: -1
opt_io_size: 0
min_io_size: 0
physical_block_size: 512
logical_block_size: 512
drive: ide1-cd0
realized: True
type: ide-cd

/machine/unattached/device[21]
parent_bus: /machine/i440fx/pci.0
command_serr_enable: True
legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile:
legacy-romfile: <null>
addr: 9
legacy-addr: 01.1
realized: True
type: piix3-ide

/machine/unattached/device[21]/ide.1
child[0]: /machine/unattached/device[22]
type: IDE

/machine/unattached/device[21]/ide.0
type: IDE

/machine/unattached/device[20]
parent_bus: /machine/i440fx/pci.0
command_serr_enable: True
legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile: efi-e1000.rom
legacy-romfile: "efi-e1000.rom"
addr: 24
legacy-addr: 03.0
autonegotiation: True
legacy-autonegotiation: on
bootindex: -1
netdev: hub0port0
vlan: 0
legacy-vlan: 0
mac: 52:54:00:12:34:56
realized: True
type: e1000

/machine/unattached/device[19]
parent_bus: /machine/unattached/device[5]/isa.0
check_media_rate: True
legacy-check_media_rate: on
bootindexB: -1
bootindexA: -1
driveB:
driveA: floppy0
dma: 2
irq: 6
iobase: 1008
legacy-iobase: 0x3f0
realized: True
type: isa-fdc

/machine/unattached/device[18]
parent_bus: /machine/unattached/device[5]/isa.0
realized: True
type: port92

/machine/unattached/device[17]
parent_bus: /machine/unattached/device[5]/isa.0
legacy-ps2_mouse: <EXCEPTION>
realized: True
type: vmmouse

/machine/unattached/device[16]
parent_bus: /machine/unattached/device[5]/isa.0
realized: True
type: vmport

/machine/unattached/device[15]
parent_bus: /machine/unattached/device[5]/isa.0
realized: True
type: i8042

/machine/unattached/device[14]
parent_bus: /machine/unattached/device[5]/isa.0
chardev: parallel0
irq: 7
iobase: 888
legacy-iobase: 0x378
index: 0
realized: True
type: isa-parallel

/machine/unattached/device[13]
parent_bus: /machine/unattached/device[5]/isa.0
wakeup: 0
chardev: serial0
irq: 4
iobase: 1016
legacy-iobase: 0x3f8
index: 0
realized: True
type: isa-serial

/machine/unattached/device[12]
parent_bus: /machine/unattached/device[5]/isa.0
legacy-pit: <EXCEPTION>
iobase: 97
legacy-iobase: 0x61
realized: True
type: isa-pcspk

/machine/unattached/device[11]
parent_bus: /machine/unattached/device[5]/isa.0
lost_tick_policy: delay
iobase: 64
legacy-iobase: 0x40
realized: True
type: kvm-pit

/machine/unattached/device[10]
date: {u'tm_sec': 31, u'tm_hour': 23, u'tm_mday': 27, u'tm_year': 113, u'tm_mon': 6, u'tm_min': 5}
parent_bus: /machine/unattached/device[5]/isa.0
lost_tick_policy: discard
base_year: 0
realized: True
type: mc146818rtc

/machine/unattached/device[9]
parent_bus: /machine/unattached/sysbus
msi: False
legacy-msi: off
timers: 3
realized: True
type: hpet

/machine/unattached/device[8]
parent_bus: /machine/i440fx/pci.0
command_serr_enable: True
legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile: vgabios-cirrus.bin
legacy-romfile: "vgabios-cirrus.bin"
addr: 16
legacy-addr: 02.0
vgamem_mb: 8
realized: True
type: cirrus-vga

/machine/unattached/device[7]
parent_bus: /machine/unattached/device[5]/isa.0
master: False
legacy-master: off
elcr_mask: 222
legacy-elcr_mask: 0xde
elcr_addr: 1233
legacy-elcr_addr: 0x4d1
iobase: 160
legacy-iobase: 0xa0
realized: True
type: kvm-i8259

/machine/unattached/device[6]
parent_bus: /machine/unattached/device[5]/isa.0
master: True
legacy-master: on
elcr_mask: 248
legacy-elcr_mask: 0xf8
elcr_addr: 1232
legacy-elcr_addr: 0x4d0
iobase: 32
legacy-iobase: 0x20
realized: True
type: kvm-i8259

/machine/unattached/device[5]
parent_bus: /machine/i440fx/pci.0
command_serr_enable: True
legacy-command_serr_enable: on
multifunction: True
legacy-multifunction: on
rombar: 1
romfile:
legacy-romfile: <null>
addr: 8
legacy-addr: 01.0
realized: True
type: PIIX3

/machine/unattached/device[5]/isa.0
child[12]: /machine/unattached/device[32]
child[11]: /machine/unattached/device[19]
child[10]: /machine/unattached/device[18]
child[9]: /machine/unattached/device[17]
child[8]: /machine/unattached/device[16]
child[7]: /machine/unattached/device[15]
child[6]: /machine/unattached/device[14]
child[5]: /machine/unattached/device[13]
child[4]: /machine/unattached/device[12]
child[3]: /machine/unattached/device[11]
child[2]: /machine/unattached/device[10]
child[1]: /machine/unattached/device[7]
child[0]: /machine/unattached/device[6]
type: ISA

/machine/unattached/device[4]
parent_bus: /machine/i440fx/pci.0
command_serr_enable: True
legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile:
legacy-romfile: <null>
addr: 0
legacy-addr: 00.0
realized: True
type: i440FX

/machine/unattached/device[3]
parent_bus: /machine/unattached/sysbus
rom_only: 1
isapc_ram_fw: 0
realized: True
type: pc-sysfw

/machine/unattached/device[2]
parent_bus: /machine/unattached/sysbus
realized: True
type: kvmclock

/machine/unattached/device[1]
parent_bus: /machine/unattached/sysbus
realized: True
type: kvmvapic

/machine/unattached/device[0]
filtered-features: [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, u'features': 0}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 3221225473, u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 2147483649, u'features': 100}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483649, u'features': 0}, {u'cpuid-register': u'EBX', u'cpuid-input-eax': 7, u'features': 0, u'cpuid-input-ecx': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 1, u'features': 0}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 1, u'features': 0}]
feature-words: [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, u'features': 16777339}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 3221225473, u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 2147483649, u'features': 1}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483649, u'features': 563194877}, {u'cpuid-register': u'EBX', u'cpuid-input-eax': 7, u'features': 0, u'cpuid-input-ecx': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 1, u'features': 2155880449}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 1, u'features': 126614525}]
apic-id: 0
tsc-frequency: 0
model-id: QEMU Virtual CPU version 1.5.50
vendor: GenuineIntel
xlevel: 2147483658
level: 4
stepping: 3
model: 2
family: 6
parent_bus: /machine/icc-bridge/icc
realized: True
type: x86_64-cpu

/machine/unattached/device[0]/apic
parent_bus: /machine/icc-bridge/icc
vapic: True
legacy-vapic: on
id: 0
realized: True
type: kvm-apic

/machine/unattached/sysbus
child[7]: /machine/unattached/device[9]
child[6]: /machine/i440fx/ioapic
child[5]: /machine/i440fx
child[4]: /machine/fw_cfg
child[3]: /machine/unattached/device[3]
child[2]: /machine/unattached/device[2]
child[1]: /machine/unattached/device[1]
child[0]: /machine/icc-bridge
type: System

/machine/peripheral
type: container

/machine/peripheral-anon
type: container

/machine
type: container

/machine/fw_cfg
parent_bus: /machine/unattached/sysbus
data_iobase: 1297
legacy-data_iobase: 0x511
ctl_iobase: 1296
legacy-ctl_iobase: 0x510
realized: True
type: fw_cfg

/machine/icc-bridge
parent_bus: /machine/unattached/sysbus
realized: True
type: icc-bridge

/machine/icc-bridge/icc
child[1]: /machine/unattached/device[0]/apic
child[0]: /machine/unattached/device[0]
type: icc-bus

/machine/unattached
type: container

/machine/unattached/device[32]
parent_bus: /machine/unattached/device[5]/isa.0
ioport: 1285
realized: True
type: pvpanic

/machine/unattached/device[31]
parent_bus: /machine/unattached/device[4]/pcie.0
command_serr_enable: True legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile: efi-e1000.rom
legacy-romfile: "efi-e1000.rom"
addr: 16
legacy-addr: 02.0
autonegotiation: True
legacy-autonegotiation: on
bootindex: -1
netdev: hub0port0
vlan: 0
legacy-vlan: 0
mac: 52:54:00:12:34:56
realized: True
type: e1000

/machine/unattached/device[30]
parent_bus: /machine/unattached/device[4]/pcie.0
command_serr_enable: True legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile: vgabios-cirrus.bin
legacy-romfile: "vgabios-cirrus.bin"
addr: 8
legacy-addr: 01.0
vgamem_mb: 8
realized: True
type: cirrus-vga

/machine/unattached/device[29]
parent_bus: /machine/unattached/device[21]/i2c
address: 87
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[28]
parent_bus: /machine/unattached/device[21]/i2c
address: 86
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[27]
parent_bus: /machine/unattached/device[21]/i2c
address: 85
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[26]
parent_bus: /machine/unattached/device[21]/i2c
address: 84
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[25]
parent_bus: /machine/unattached/device[21]/i2c
address: 83
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[24]
parent_bus: /machine/unattached/device[21]/i2c
address: 82
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[23]
parent_bus: /machine/unattached/device[21]/i2c
address: 81
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[22]
parent_bus: /machine/unattached/device[21]/i2c
address: 80
legacy-data: <EXCEPTION>
realized: True
type: smbus-eeprom

/machine/unattached/device[21]
parent_bus: /machine/unattached/device[4]/pcie.0
command_serr_enable: True legacy-command_serr_enable: on
multifunction: True
legacy-multifunction: on
rombar: 1
romfile:
legacy-romfile: <null>
addr: 251
legacy-addr: 1f.3
realized: True
type: ICH9 SMB

/machine/unattached/device[21]/i2c
child[7]: /machine/unattached/device[29]
child[6]: /machine/unattached/device[28]
child[5]: /machine/unattached/device[27]
child[4]: /machine/unattached/device[26]
child[3]: /machine/unattached/device[25]
child[2]: /machine/unattached/device[24]
child[1]: /machine/unattached/device[23]
child[0]: /machine/unattached/device[22]
type: i2c-bus

/machine/unattached/device[20]
parent_bus: /machine/unattached/device[4]/pcie.0
command_serr_enable: True legacy-command_serr_enable: on
multifunction: True
legacy-multifunction: on
rombar: 1
romfile:
legacy-romfile: <null>
addr: 250
legacy-addr: 1f.2
realized: True
type: ich9-ahci

/machine/unattached/device[20]/ide.5
type: IDE

/machine/unattached/device[20]/ide.4
type: IDE

/machine/unattached/device[20]/ide.3
type: IDE

/machine/unattached/device[20]/ide.2
type: IDE

/machine/unattached/device[20]/ide.1
type: IDE

/machine/unattached/device[20]/ide.0
type: IDE

/machine/unattached/device[19]
parent_bus: /machine/unattached/device[5]/isa.0
check_media_rate: True
legacy-check_media_rate: on
bootindexB: -1
bootindexA: -1
driveB:
driveA: floppy0
dma: 2
irq: 6
iobase: 1008
legacy-iobase: 0x3f0
realized: True
type: isa-fdc

/machine/unattached/device[18]
parent_bus: /machine/unattached/device[5]/isa.0
realized: True
type: port92

/machine/unattached/device[17]
parent_bus: /machine/unattached/device[5]/isa.0
legacy-ps2_mouse: <EXCEPTION>
realized: True
type: vmmouse

/machine/unattached/device[16]
parent_bus: /machine/unattached/device[5]/isa.0
realized: True
type: vmport

/machine/unattached/device[15]
parent_bus: /machine/unattached/device[5]/isa.0
realized: True
type: i8042

/machine/unattached/device[14]
parent_bus: /machine/unattached/device[5]/isa.0
chardev: parallel0
irq: 7
iobase: 888
legacy-iobase: 0x378
index: 0
realized: True
type: isa-parallel

/machine/unattached/device[13]
parent_bus: /machine/unattached/device[5]/isa.0
wakeup: 0
chardev: serial0
irq: 4
iobase: 1016
legacy-iobase: 0x3f8
index: 0
realized: True
type: isa-serial

/machine/unattached/device[12]
parent_bus: /machine/unattached/device[5]/isa.0
legacy-pit: <EXCEPTION>
iobase: 97
legacy-iobase: 0x61
realized: True
type: isa-pcspk

/machine/unattached/device[11]
parent_bus: /machine/unattached/device[5]/isa.0
lost_tick_policy: delay
iobase: 64
legacy-iobase: 0x40
realized: True
type: kvm-pit

/machine/unattached/device[10]
date: {u'tm_sec': 42, u'tm_hour': 23, u'tm_mday': 27, u'tm_year': 113, u'tm_mon': 6, u'tm_min': 4}
parent_bus: /machine/unattached/device[5]/isa.0
lost_tick_policy: discard
base_year: 0
realized: True
type: mc146818rtc

/machine/unattached/device[9]
parent_bus: /machine/unattached/sysbus
msi: False
legacy-msi: off
timers: 3
realized: True
type: hpet

/machine/unattached/device[8]
parent_bus: /machine/unattached/sysbus
gsi_base: 0
realized: True
type: kvm-ioapic

/machine/unattached/device[7]
parent_bus: /machine/unattached/device[5]/isa.0
master: False
legacy-master: off
elcr_mask: 222
legacy-elcr_mask: 0xde
elcr_addr: 1233
legacy-elcr_addr: 0x4d1
iobase: 160
legacy-iobase: 0xa0
realized: True
type: kvm-i8259

/machine/unattached/device[6]
parent_bus: /machine/unattached/device[5]/isa.0
master: True
legacy-master: on
elcr_mask: 248
legacy-elcr_mask: 0xf8
elcr_addr: 1232
legacy-elcr_addr: 0x4d0
iobase: 32
legacy-iobase: 0x20
realized: True
type: kvm-i8259

/machine/unattached/device[5]
parent_bus: /machine/unattached/device[4]/pcie.0
command_serr_enable: True legacy-command_serr_enable: on
multifunction: True
legacy-multifunction: on
rombar: 1
romfile:
legacy-romfile: <null>
addr: 248
legacy-addr: 1f.0
realized: True
type: ICH9 LPC

/machine/unattached/device[5]/isa.0
child[12]: /machine/unattached/device[32]
child[11]: /machine/unattached/device[19]
child[10]: /machine/unattached/device[18]
child[9]: /machine/unattached/device[17]
child[8]: /machine/unattached/device[16]
child[7]: /machine/unattached/device[15]
child[6]: /machine/unattached/device[14]
child[5]: /machine/unattached/device[13]
child[4]: /machine/unattached/device[12]
child[3]: /machine/unattached/device[11]
child[2]: /machine/unattached/device[10]
child[1]: /machine/unattached/device[7]
child[0]: /machine/unattached/device[6]
type: ISA

/machine/unattached/device[4]
parent_bus: /machine/unattached/sysbus
MCFG: -1
realized: True
type: q35-pcihost

/machine/unattached/device[4]/pcie.0
child[5]: /machine/unattached/device[31]
child[4]: /machine/unattached/device[30]
child[3]: /machine/unattached/device[21]
child[2]: /machine/unattached/device[20]
child[1]: /machine/unattached/device[5]
child[0]: /machine/unattached/device[4]/mch
type: PCIE

/machine/unattached/device[4]/mch
parent_bus: /machine/unattached/device[4]/pcie.0
command_serr_enable: True legacy-command_serr_enable: on
multifunction: False
legacy-multifunction: off
rombar: 1
romfile:
legacy-romfile: <null>
addr: 0
legacy-addr: 00.0
realized: True
type: mch

/machine/unattached/device[3]
parent_bus: /machine/unattached/sysbus
rom_only: 1
isapc_ram_fw: 0
realized: True
type: pc-sysfw

/machine/unattached/device[2]
parent_bus: /machine/unattached/sysbus
realized: True
type: kvmclock

/machine/unattached/device[1]
parent_bus: /machine/unattached/sysbus
realized: True
type: kvmvapic

/machine/unattached/device[0]
filtered-features: [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, u'features': 0}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 3221225473, u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 2147483649, u'features': 100}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483649, u'features': 0}, {u'cpuid-register': u'EBX', u'cpuid-input-eax': 7, u'features': 0, u'cpuid-input-ecx': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 1, u'features': 0}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 1, u'features': 0}]
feature-words: [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, u'features': 16777339}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 3221225473, u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 2147483649, u'features': 1}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483649, u'features': 563194877}, {u'cpuid-register': u'EBX', u'cpuid-input-eax': 7, u'features': 0, u'cpuid-input-ecx': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 1, u'features': 2155880449}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 1, u'features': 126614525}]
apic-id: 0
tsc-frequency: 0
model-id: QEMU Virtual CPU version 1.5.50
vendor: GenuineIntel
xlevel: 2147483658
level: 4
stepping: 3
model: 2
family: 6
parent_bus: /machine/icc-bridge/icc
realized: True
type: x86_64-cpu

/machine/unattached/device[0]/apic
parent_bus: /machine/icc-bridge/icc
vapic: True
legacy-vapic: on
id: 0
realized: True
type: kvm-apic

/machine/unattached/sysbus
child[7]: /machine/unattached/device[9]
child[6]: /machine/unattached/device[8]
child[5]: /machine/unattached/device[4]
child[4]: /machine/fw_cfg
child[3]: /machine/unattached/device[3]
child[2]: /machine/unattached/device[2]
child[1]: /machine/unattached/device[1]
child[0]: /machine/icc-bridge
type: System

/machine/peripheral
type: container

/machine/peripheral-anon
type: container

#!/usr/bin/python
##
# QEMU Object Model test tools
#
# Copyright IBM, Corp. 2011
#
# Authors:

#  Anthony Liguori   <[email protected]>
#  Andreas Faerber   <[email protected]>
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.  See
# the COPYING file in the top-level directory.
##

import sys
import os
from qmp import QEMUMonitorProtocol

cmd, args = sys.argv[0], sys.argv[1:]
socket_path = None
path = None
prop = None

def usage():
return '''environment variables:
QMP_SOCKET=<path | addr:port>
usage:

    %s [-h] [-s <QMP socket path | addr:port>] [<path>]

''' % cmd

def usage_error(error_msg = "unspecified error"):

    sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg))
    exit(1)

if len(args) > 0:

    if args[0] == "-h":
        print usage()
        exit(0);
    elif args[0] == "-s":
        try:
            socket_path = args[1]
        except:
            usage_error("missing argument: QMP socket path or address");
        args = args[2:]

if not socket_path:
if os.environ.has_key('QMP_SOCKET'):
socket_path = os.environ['QMP_SOCKET']
else:
usage_error("no QMP socket path or address given");

srv = QEMUMonitorProtocol(socket_path)
srv.connect()

def list_node(path):

    print '%s' % path
    items = srv.command('qom-list', path=path)
    for item in items:
        if not item['type'].startswith('child<'): #and not item['type'].startswith('link<'):
            try:
                print '  %s: %s' % (item['name'], srv.command('qom-get', path=path, property=item['name']))
            except:
                print '  %s: <EXCEPTION>' % item['name']
    print ''
    for item in items:
        if item['type'].startswith('child<'):
            list_node(path + '/' + item['name'])

list_node('/machine')

#65 lore raw
Quoted 73 lines · Andreas Färber

Am 26.07.2013 14:19, schrieb Andreas Färber:

Quoted 56 lines

Am 25.07.2013 18:19, schrieb Michael S. Tsirkin:

Quoted 46 lines · Andreas Färber
Quoted 45 lines

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

I believe Anthony asked to extract the information from the QOM tree, originally from the SeaBIOS side, then later agreeing to do it on the QEMU side.

However here I am still seeing *functions* added in device code to check device existence and to extract individual fields. I was assuming (and clearly prefer) such code to live in a central place, be it acpi-build.c or something else, and to use QOM *API*s to obtain information when needed rather than building up lots of new structs duplicating that data. That would at the same time be a test case for how useful the QOM tree is

I'm not sure if there was a misunderstanding or whether the PC QOM model still sucks^W is incomplete? Anthony and Ping Fang(?) had both posted patches to improve the composition tree once. If there's properties missing that you need to access for ACPI, we should simply add them. For i440fx we have /machine/i440fx.
For q35 I encountered an mch child on q35-pcihost, but what's trivially missing apparently is to add q35-pcihost as a child to /machine, e.g. /machine/q35.
Then you'll end up doing
Object *obj = object_resolve_path_component(qdev_get_machine(), "q35/mch"); object_property_get_int(obj, "foo", &err); object_property_get_string(obj, "bar", &err);
and so on. No need to do the TYPE_... based search for everything.

User-added -devices will show up in /machine/peripheral or /machine/peripheral-anon depending on whether id= is used, so there a type-based search probably makes sense. And there is nothing wrong with moving the TYPE_* constants to a device header where not yet the case, to allow that from generic code.

Similarly, please don't open-code OBJECT_CHECK()s, do a trivial patch with a macro that we can then reuse elsewhere. I'd be happy to review such QOM patches and help fast-track them into master.

Quoted 8 lines
Quoted 1 line

Will take a closer look at the implementation later.

This is not my understanding of previous comments on list or on KVM call.

Basically it sounds like you want to make my work depend on completion of QOM conversion.
I think we explicitly agreed full QOM convertion is not a blocker.

Quoted 8 lines

Not sure what you mean with "completion of QOM conversion" or "full QOM conversion". What I am saying is that instead of spending time adding functions to devices that fulfill your own ACPI needs only, that time were better spent adding QOM properties where not yet existent.

Because then what you can access for ACPI can also be accessed by libvirt and other management tools as well as qtest - I consider it a test case. QMP does not offer an instance/path search by type.

To clarify for everyone what we're talking about here, I'm attaching /machine composition tree dumps for pc,accel=kvm and q35,accel=kvm plus the rudimentary script I used to generate it.

It shows for instance the mentioned /machine/i440fx and lack of /machine/q35. It also shows that there would be a /machine/fw_cfg.

Quoted 8 lines

Paths starting with /machine/unassigned shouldn't be hardcoded anywhere (that's the nobody-added-it-as-a-child<> bucket), except maybe for /machine/unassigned/sysbus. But whenever there's a link from a named device to a /machine/unassigned/device[n] that may of course be used dynamically, e.g. /machine/icc-bridge/icc to discover CPUs and APICs.

HTH,
Andreas

So q35 is all "unassigned".
I assume it's fine to use APIs for that, then?

Signature · 1 line
MST
#66 lore raw
In reply to Andreas Färber
Quoted 8 lines · Andreas Färber

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

By the way, for examples which are exactly
like this code here, look no further than:

	FWCfgState *fw_cfg_find(void);

and the use in hw/misc/pvpanic.c of said API.

Here we have device implementing an API to find it, and through this pointer, it is accessed by more APIs access its state.

This is exactly what my patches do for piix etc.

So if you don't like this approach, please change
existing code using it.

Signature · 1 line
MST
#67 lore raw

Am 25.07.2013 19:18, schrieb Michael S. Tsirkin:

Quoted 17 lines · Andreas Färber
Quoted 8 lines

Am 24.07.2013 18:01, schrieb Michael S. Tsirkin:

Quoted 4 lines

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

Quite frankly, this is still not looking the way I imagined it based on the KVM call discussion and Anthony's comments that I remember:

By the way, for examples which are exactly
like this code here, look no further than:

	FWCfgState *fw_cfg_find(void);

and the use in hw/misc/pvpanic.c of said API.

Quoted 7 lines

Here we have device implementing an API to find it, and through this pointer, it is accessed by more APIs access its state.

This is exactly what my patches do for piix etc.

So if you don't like this approach, please change
existing code using it.

According to git-blame that code was recently added by you:
http://repo.or.cz/w/qemu.git/commit/600c60b76d0682f6c39d19bfff79da9321e8cf86?f=hw/nvram/fw_cfg.c

So the existing-code argument is kind of moot. ;)

Further, that returns the device's state struct and does not copy fields from that state struct into another state struct.

BTW if you want to avoid repeatedly hardcoding things, fw_cfg should be using object_resolve_path_component(), I'll prepare a patch.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#68 lore raw
In reply to Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin

This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi

Please review, and consider for 1.6.

This isn't ready for 1.6 so it's going to have to wait for 1.7.

Regards,

Anthony Liguori

Quoted 135 lines

Changes from v2 repost:
- address comment by Anthony - convert to use APIs implemented using QOM
- address comment by Anthony - avoid tricky pointer path, use GArray from glib instead
- Address lots of comments by Hu Tao and Laszlo Ersek
- rebase to latest bits

Changes from v2:
- added missing patches to make it actually build Changes from v1 RFC:
- added code to address cross version compatibility
- rebased to latest bits
- updated seabios code to latest bits (added pvpanic device)

This patchset moves all generation of ACPI tables from guest BIOS to the hypervisor.

Although ACPI tables come from a system BIOS on real hw, it makes sense that the ACPI tables are coupled with the virtual machine, since they have to abstract the x86 machine to the OS's.

This is widely desired as a way to avoid the churn and proliferation of QEMU-specific interfaces associated with ACPI tables in bios code.

There's a bit of code duplication where we already declare similar acpi structures in qemu.

I think it's best to do it in this order: port code directly, and apply cleanups and reduce duplication that results, on top.
This way it's much easier to see that we don't introduce regressions.

In particular, I booted a guest on qemu with and without the change, and verified that ACPI tables are unchanged except for trivial pointer address changes.

Such binary compatibility makes it easier to be confident that this change won't break things.

Michael S. Tsirkin (14):
hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h
i386: add ACPI table files from seabios
acpi: add rules to compile ASL source
acpi: pre-compiled ASL files
loader: use file path size from fw_cfg.h
i386: add bios linker/loader
loader: support for unmapped ROM blobs
loader: allow adding ROMs in done callbacks
i386: define pc guest info
ich9: APIs for pc guest info
piix: APIs for pc guest info
pvpanic: add API to access io port
hpet: add API to find it
i386: ACPI table generation code from seabios

 configure                            |    9 +-
 hw/acpi/ich9.c                       |    6 +
 hw/acpi/piix4.c                      |   29 +-
 hw/core/loader.c                     |   40 +-
 hw/i386/Makefile.objs                |   27 +
 hw/i386/acpi-build.c                 |  907 +++++
 hw/i386/acpi-defs.h                  |  327 ++
 hw/i386/acpi-dsdt-cpu-hotplug.dsl    |   93 +
 hw/i386/acpi-dsdt-dbug.dsl           |   41 +
 hw/i386/acpi-dsdt-hpet.dsl           |   51 +
 hw/i386/acpi-dsdt-isa.dsl            |  117 +
 hw/i386/acpi-dsdt-pci-crs.dsl        |  105 +
 hw/i386/acpi-dsdt.dsl                |  343 ++
 hw/i386/acpi-dsdt.hex.generated      | 4409 ++++++++++++++++++++
 hw/i386/bios-linker-loader.c         |  156 +
 hw/i386/pc.c                         |   37 +-
 hw/i386/pc_piix.c                    |    5 +
 hw/i386/pc_q35.c                     |    3 +
 hw/i386/q35-acpi-dsdt.dsl            |  452 +++
 hw/i386/q35-acpi-dsdt.hex.generated  | 7346 ++++++++++++++++++++++++++++++++++
 hw/i386/ssdt-misc.dsl                |  119 +
 hw/i386/ssdt-misc.hex.generated      |  190 +
 hw/i386/ssdt-pcihp.dsl               |   51 +
 hw/i386/ssdt-pcihp.hex.generated     |  108 +
 hw/i386/ssdt-proc.dsl                |   63 +
 hw/i386/ssdt-proc.hex.generated      |  134 +
 hw/isa/lpc_ich9.c                    |   19 +
 hw/lm32/lm32_hwsetup.h               |    2 +-
 hw/mips/mips_malta.c                 |    2 +-
 hw/misc/pvpanic.c                    |   11 +
 hw/pci-host/piix.c                   |    8 +
 hw/pci-host/q35.c                    |   10 +
 hw/timer/hpet.c                      |    5 +
 include/hw/acpi/ich9.h               |    2 +
 include/hw/i386/acpi-build.h         |    9 +
 include/hw/i386/apic.h               |    2 +
 include/hw/i386/bios-linker-loader.h |   26 +
 include/hw/i386/ich9.h               |    3 +
 include/hw/i386/pc.h                 |   34 +
 include/hw/loader.h                  |    5 +-
 include/hw/nvram/fw_cfg.h            |    4 +-
 include/hw/pci-host/q35.h            |    2 +
 include/hw/timer/hpet.h              |    2 +
 include/qemu/typedefs.h              |    2 +
 scripts/acpi_extract.py              |  362 ++
 scripts/acpi_extract_preprocess.py   |   51 +
 scripts/update-acpi.sh               |    4 +
 vl.c                                 |    3 +
 48 files changed, 15721 insertions(+), 15 deletions(-)
 create mode 100644 hw/i386/acpi-build.c
 create mode 100644 hw/i386/acpi-defs.h
 create mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl
 create mode 100644 hw/i386/acpi-dsdt-dbug.dsl
 create mode 100644 hw/i386/acpi-dsdt-hpet.dsl
 create mode 100644 hw/i386/acpi-dsdt-isa.dsl
 create mode 100644 hw/i386/acpi-dsdt-pci-crs.dsl
 create mode 100644 hw/i386/acpi-dsdt.dsl
 create mode 100644 hw/i386/acpi-dsdt.hex.generated
 create mode 100644 hw/i386/bios-linker-loader.c
 create mode 100644 hw/i386/q35-acpi-dsdt.dsl
 create mode 100644 hw/i386/q35-acpi-dsdt.hex.generated
 create mode 100644 hw/i386/ssdt-misc.dsl
 create mode 100644 hw/i386/ssdt-misc.hex.generated
 create mode 100644 hw/i386/ssdt-pcihp.dsl
 create mode 100644 hw/i386/ssdt-pcihp.hex.generated
 create mode 100644 hw/i386/ssdt-proc.dsl
 create mode 100644 hw/i386/ssdt-proc.hex.generated
 create mode 100644 include/hw/i386/acpi-build.h
 create mode 100644 include/hw/i386/bios-linker-loader.h
 create mode 100755 scripts/acpi_extract.py
 create mode 100755 scripts/acpi_extract_preprocess.py
 create mode 100644 scripts/update-acpi.sh
Signature · 1 line
MST