acpi, pci, pc, virtio fixes and enhancements
The following changes since commit 1cf892ca2689c84960b4ce4d2723b6bee453711c:
SPARC: Fix LEON3 power down instruction (2014-01-15 15:37:33 +1000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
for you to fetch changes up to ed25eb3675186b7bbb0c9876fe0e7cf8fa868642:
acpi-test: update expected AML since recent changes (2014-01-20 16:06:14 +0200)
----------------------------------------------------------------
acpi,pci,pc,virtio fixes and enhancements
This includes new unit-tests for acpi by Marcel, hotplug for pci bridges by myself (piix only so far) and cpu hotplug for q35.
And a bunch of fixes all over the place as usual.
Still keeping memory alignment fix for q35 out of tree in the hope that we can fix it without limiting 32 bit guests to 2G RAM.
----------------------------------------------------------------
Alexey Kardashevskiy (1):
tests: fix acpi to work on bigendian host
Gabriel L. Somlo (2):
Add DSDT node for AppleSMC
ACPI: Fix AppleSMC _STA size
Igor Mammedov (9):
pc: make: fix dependencies: rebuild when included file is changed
acpi: factor out common cpu hotplug code for PIIX4/Q35
acpi: ich9: add CPU hotplug handling to Q35 machine
pc: set PRST base in DSDT depending on chipset
pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 IO range from PCI bus resources
pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources
pc: ACPI: expose PRST IO range via _CRS
pc: ACPI: unify source of CPU hotplug IO base/len
pc: ACPI: update acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generated
Laszlo Ersek (1):
Python-lang gdb script to extract x86_64 guest vmcore from qemu coredump
Marcel Apfelbaum (10):
acpi unit-test: add test files
configure: added acpi unit-test files
acpi unit-test: compare DSDT and SSDT tables against expected values
configure: add CONFIG_IASL to config-host.h
acpi unit-test: extract iasl executable from configuration acpi unit-test: added script to rebuild the expected aml files acpi unit-test: hook to rebuild expected aml files
acpi unit-test: renamed ssdt_tables to tables
acpi unit-test: resolved iasl crash
acpi unit-test: do not fail on asl mismatch
Michael S. Tsirkin (5):
pci: add pci_for_each_bus_depth_first
pcihp: generalization of piix4 acpi
piix4: add acpi pci hotplug support
acpi-build: enable hotplug for PCI bridges
acpi-test: update expected AML since recent changes
Stefan Weil (1):
virtio: Fix return value for dummy function vhost_net_virtqueue_pending
configure | 4 + include/hw/acpi/cpu_hotplug.h | 27 ++ include/hw/acpi/cpu_hotplug_defs.h | 24 ++ include/hw/acpi/ich9.h | 4 + include/hw/acpi/pcihp.h | 72 ++++++ include/hw/i386/pc.h | 5 + include/hw/isa/isa.h | 7 + include/hw/pci/pci.h | 14 ++ hw/acpi/cpu_hotplug.c | 64 +++++ hw/acpi/ich9.c | 14 ++ hw/acpi/pcihp.c | 316 ++++++++++++++++++++++++ hw/acpi/piix4.c | 155 ++++++------ hw/i386/acpi-build.c | 354 +++++++++++++++++++++------ hw/misc/applesmc.c | 1 - hw/net/vhost_net.c | 2 +- hw/pci/pci.c | 28 +++ tests/acpi-test.c | 305 ++++++++++++++++++++--- docs/specs/acpi_cpu_hotplug.txt | 4 +- hw/acpi/Makefile.objs | 3 +- hw/i386/Makefile.objs | 2 +- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 14 +- hw/i386/acpi-dsdt-isa.dsl | 11 + hw/i386/acpi-dsdt-pci-crs.dsl | 15 +- hw/i386/acpi-dsdt.dsl | 76 ++++-- hw/i386/acpi-dsdt.hex.generated | 217 +++++++++++----- hw/i386/q35-acpi-dsdt.dsl | 19 ++ hw/i386/q35-acpi-dsdt.hex.generated | 74 +++++- hw/i386/ssdt-pcihp.dsl | 11 +- hw/i386/ssdt-pcihp.hex.generated | 20 +- hw/i386/ssdt-proc.hex.generated | 6 +- scripts/create_config | 4 + scripts/dump-guest-memory.py | 339 +++++++++++++++++++++++++ tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes tests/acpi-test-data/pc/DSDT | Bin 0 -> 4582 bytes tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes tests/acpi-test-data/pc/SSDT | Bin 0 -> 2200 bytes tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes tests/acpi-test-data/q35/DSDT | Bin 0 -> 7438 bytes tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes tests/acpi-test-data/q35/SSDT | Bin 0 -> 475 bytes tests/acpi-test-data/rebuild-expected-aml.sh | 36 +++ 46 files changed, 1927 insertions(+), 320 deletions(-) create mode 100644 include/hw/acpi/cpu_hotplug.h create mode 100644 include/hw/acpi/cpu_hotplug_defs.h create mode 100644 include/hw/acpi/pcihp.h create mode 100644 hw/acpi/cpu_hotplug.c create mode 100644 hw/acpi/pcihp.c create mode 100644 scripts/dump-guest-memory.py create mode 100644 tests/acpi-test-data/pc/APIC create mode 100644 tests/acpi-test-data/pc/DSDT create mode 100644 tests/acpi-test-data/pc/FACP create mode 100644 tests/acpi-test-data/pc/FACS create mode 100644 tests/acpi-test-data/pc/HPET create mode 100644 tests/acpi-test-data/pc/SSDT create mode 100644 tests/acpi-test-data/q35/APIC create mode 100644 tests/acpi-test-data/q35/DSDT create mode 100644 tests/acpi-test-data/q35/FACP create mode 100644 tests/acpi-test-data/q35/FACS create mode 100644 tests/acpi-test-data/q35/HPET create mode 100644 tests/acpi-test-data/q35/MCFG create mode 100644 tests/acpi-test-data/q35/SSDT create mode 100755 tests/acpi-test-data/rebuild-expected-aml.sh
[Qemu-devel] [PULL 01/29] Python-lang gdb script to extract x86_64 guest vmcore from qemu coredump
From: Laszlo Ersek <[email protected]>
When qemu dies unexpectedly, for example in response to an explicit abort() call, or (more importantly) when an external signal is delivered to it that results in a coredump, sometimes it is useful to extract the guest vmcore from the qemu process' memory image. The guest vmcore might help understand an emulation problem in qemu, or help debug the guest.
This script reimplements (and cuts many features of) the qmp_dump_guest_memory() command in gdb/Python,
https://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html
working off the saved memory image of the qemu process. The docstring in the patch (serving as gdb help text) describes the limitations relative to the QMP command.
Dependencies of qmp_dump_guest_memory() have been reimplemented as needed. I sought to follow the general structure, sticking to original function names where possible. However, keeping it simple prevailed in some places.
The patch has been tested with a 4 VCPU, 768 MB, RHEL-6.4 (2.6.32-358.el6.x86_64) guest:
- The script printed
Quoted 13 lines
guest RAM blocks:
target_starttarget_endhost_addrmessage count
---------------- ---------------- ---------------- ------- -----0000000000000000 00000000000a0000 00007f95d0000000 added 1 00000000000a0000 00000000000b0000 00007f960ac00000 added 2 00000000000c0000 00000000000ca000 00007f95d00c0000 added 3 00000000000ca000 00000000000cd000 00007f95d00ca000 joined 3 00000000000cd000 00000000000d0000 00007f95d00cd000 joined 3 00000000000d0000 00000000000f0000 00007f95d00d0000 joined 3 00000000000f0000 0000000000100000 00007f95d00f0000 joined 3 0000000000100000 0000000030000000 00007f95d0100000 joined 3 00000000fc000000 00000000fc800000 00007f960ac00000 added 4 00000000fffe0000 0000000100000000 00007f9618800000 added 5
Quoted 5 lines
dumping range at
00007f95d0000000for length00000000000a0000dumping range at00007f960ac00000for length 0000000000010000 dumping range at00007f95d00c0000for length000000002ff40000dumping range at00007f960ac00000for length 0000000000800000 dumping range at00007f9618800000for length 0000000000020000
- The vmcore was checked with "readelf", comparing the results against a vmcore written by qmp_dump_guest_memory():
Quoted 31 lines
mine 2013-09-12 17:39:03.820289404 +0200 renamed from theirs 2013-09-12 17:38:59.797289404 +0200 +7
-7@@ -27,16 +27,16 @@ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align NOTE 0x0000000000000190 0x0000000000000000 0x0000000000000000 - 0x0000000000000ca0 0x0000000000000ca0 0 - LOAD 0x0000000000000e30 0x0000000000000000 0x0000000000000000 + 0x000000000000001c 0x000000000000001c 0 + LOAD 0x00000000000001ac 0x0000000000000000 0x0000000000000000 0x00000000000a0000 0x00000000000a0000 0 - LOAD 0x00000000000a0e30 0x0000000000000000 0x00000000000a0000 + LOAD 0x00000000000a01ac 0x0000000000000000 0x00000000000a0000 0x0000000000010000 0x0000000000010000 0 - LOAD 0x00000000000b0e30 0x0000000000000000 0x00000000000c0000 + LOAD 0x00000000000b01ac 0x0000000000000000 0x00000000000c0000 0x000000002ff40000 0x000000002ff40000 0 - LOAD 0x000000002fff0e30 0x0000000000000000 0x00000000fc000000 + LOAD 0x000000002fff01ac 0x0000000000000000 0x00000000fc000000 0x0000000000800000 0x0000000000800000 0 - LOAD 0x00000000307f0e30 0x0000000000000000 0x00000000fffe0000 + LOAD 0x00000000307f01ac 0x0000000000000000 0x00000000fffe0000 0x0000000000020000 0x0000000000020000 0 There is no dynamic section in this file.@@ -47,13 +47,6 @@ No version information found in this file. -Notes at offset 0x00000190 with length 0x00000ca0: +Notes at offset 0x00000190 with length 0x0000001c:
mine 2013-09-12 17:39:03.820289404 +0200 line 52
Quoted 10 lines
mine 2013-09-12 17:39:03.820289404 +0200 renamed from theirs 2013-09-12 17:38:59.797289404 +0200 +1
-8Owner Data size Description - CORE 0x00000150 NT_PRSTATUS (prstatus structure) - CORE 0x00000150 NT_PRSTATUS (prstatus structure) - CORE 0x00000150 NT_PRSTATUS (prstatus structure) - CORE 0x00000150 NT_PRSTATUS (prstatus structure) - QEMU 0x000001b0 Unknown note type: (0x00000000) - QEMU 0x000001b0 Unknown note type: (0x00000000) - QEMU 0x000001b0 Unknown note type: (0x00000000) - QEMU 0x000001b0 Unknown note type: (0x00000000) + NONE 0x00000005 Unknown note type: (0x00000000)
- The vmcore was checked with "crash" too, again comparing the results against a vmcore written by qmp_dump_guest_memory():
Quoted 78 lines
example.dump.log2 2013-09-12 17:52:15.904289203 +0200 renamed from guest.vmcore.log2 2013-09-12 17:52:27.074289201 +0200 +12
-13@@ -22,11 +22,11 @@ This GDB was configured as "x86_64-unknown-linux-gnu"... KERNEL: /usr/lib/debug/lib/modules/2.6.32-358.el6.x86_64/vmlinux - DUMPFILE: /home/lacos/tmp/guest.vmcore + DUMPFILE: /home/lacos/tmp/example.dump CPUS: 4 - DATE: Thu Sep 12 17:16:11 2013 - UPTIME: 00:01:09 -LOAD AVERAGE: 0.07, 0.03, 0.00 + DATE: Thu Sep 12 17:17:41 2013 + UPTIME: 00:00:38 +LOAD AVERAGE: 0.18, 0.05, 0.01 TASKS: 130 NODENAME: localhost.localdomain RELEASE: 2.6.32-358.el6.x86_64@@ -38,12 +38,12 @@ COMMAND: "swapper" TASK: ffffffff81a8d020 (1 of 4) [THREAD_INFO: ffffffff81a00000] CPU: 0 - STATE: TASK_RUNNING (PANIC) + STATE: TASK_RUNNING (ACTIVE) + WARNING: panic task not found crash> bt PID: 0 TASK: ffffffff81a8d020 CPU: 0 COMMAND: "swapper" - #0 [ffffffff81a01ed0] default_idle at ffffffff8101495d - #1 [ffffffff81a01ef0] cpu_idle at ffffffff81009fc6 + #0 [ffffffff81a01ef0] cpu_idle at ffffffff81009fc6 crash> task ffffffff81a8d020 PID: 0 TASK: ffffffff81a8d020 CPU: 0 COMMAND: "swapper" struct task_struct {@@ -75,7 +75,7 @@ prev = 0xffffffff81a8d080 }, on_rq = 0, - exec_start = 8618466836, + exec_start = 7469214014, sum_exec_runtime = 0, vruntime = 0, prev_sum_exec_runtime = 0,@@ -149,7 +149,7 @@ }, tasks = { next = 0xffff88002d621948, - prev = 0xffff880029618f28 + prev = 0xffff880023b74488 }, pushable_tasks = { prio = 140,@@ -165,7 +165,7 @@ } }, mm = 0x0, - active_mm = 0xffff88002929b780, + active_mm = 0xffff8800297eb980, exit_state = 0, exit_code = 0, exit_signal = 0,@@ -177,7 +177,7 @@ sched_reset_on_fork = 0, pid = 0, tgid = 0, - stack_canary = 2483693585637059287, + stack_canary = 7266362296181431986, real_parent = 0xffffffff81a8d020, parent = 0xffffffff81a8d020, children = {@@ -224,14 +224,14 @@ set_child_tid = 0x0, clear_child_tid = 0x0, utime = 0, - stime = 3, + stime = 2, utimescaled = 0, - stimescaled = 3,
example.dump.log2 2013-09-12 17:52:15.904289203 +0200 line 237
Quoted 10 lines
example.dump.log2 2013-09-12 17:52:15.904289203 +0200 renamed from guest.vmcore.log2 2013-09-12 17:52:27.074289201 +0200 +2
-1+ stimescaled = 2, gtime = 0, prev_utime = 0, prev_stime = 0, nvcsw = 0, - nivcsw = 1000, + nivcsw = 1764, start_time = { tv_sec = 0, tv_nsec = 0
- <name_dropping>I asked for Dave Anderson's help with verifying the extracted vmcore, and his comments make me think I should post this.</name_dropping>
--- scripts/dump-guest-memory.py | 339 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 scripts/dump-guest-memory.py
scripts/dump-guest-memory.py new file +339 -0
@@ -0,0 +1,339 @@ +# This python script adds a new gdb command, "dump-guest-memory". It +# should be loaded with "source dump-guest-memory.py" at the (gdb) +# prompt. +# +# Copyright (C) 2013, Red Hat, Inc. +# +# Authors: +# Laszlo Ersek <[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. +# +# The leading docstring doesn't have idiomatic Python formatting. It is +# printed by gdb's "help" command (the first line is printed in the +# "help data" summary), and it should match how other help texts look in +# gdb. + +import struct + +class DumpGuestMemory(gdb.Command): + """Extract guest vmcore from qemu process coredump. + +The sole argument is FILE, identifying the target file to write the +guest vmcore to. + +This GDB command reimplements the dump-guest-memory QMP command in +python, using the representation of guest memory as captured in the qemu +coredump. The qemu process that has been dumped must have had the +command line option "-machine dump-guest-core=on". + +For simplicity, the "paging", "begin" and "end" parameters of the QMP +command are not supported -- no attempt is made to get the guest's +internal paging structures (ie. paging=false is hard-wired), and guest +memory is always fully dumped. + +Only x86_64 guests are supported. + +The CORE/NT_PRSTATUS and QEMU notes (that is, the VCPUs' statuses) are +not written to the vmcore. Preparing these would require context that is +only present in the KVM host kernel module when the guest is alive. A +fake ELF note is written instead, only to keep the ELF parser of "crash" +happy. + +Dependent on how busted the qemu process was at the time of the +coredump, this command might produce unpredictable results. If qemu +deliberately called abort(), or it was dumped in response to a signal at +a halfway fortunate point, then its coredump should be in reasonable +shape and this command should mostly work.""" + + TARGET_PAGE_SIZE = 0x1000 + TARGET_PAGE_MASK = 0xFFFFFFFFFFFFF000 + + # Various ELF constants + EM_X86_64 = 62 # AMD x86-64 target machine + ELFDATA2LSB = 1 # little endian + ELFCLASS64 = 2 + ELFMAG = "\x7FELF" + EV_CURRENT = 1 + ET_CORE = 4 + PT_LOAD = 1 + PT_NOTE = 4 + + # Special value for e_phnum. This indicates that the real number of + # program headers is too large to fit into e_phnum. Instead the real + # value is in the field sh_info of section 0. + PN_XNUM = 0xFFFF + + # Format strings for packing and header size calculation. + ELF64_EHDR = ("4s" # e_ident/magic + "B" # e_ident/class + "B" # e_ident/data + "B" # e_ident/version + "B" # e_ident/osabi + "8s" # e_ident/pad + "H" # e_type + "H" # e_machine + "I" # e_version + "Q" # e_entry + "Q" # e_phoff + "Q" # e_shoff + "I" # e_flags + "H" # e_ehsize + "H" # e_phentsize + "H" # e_phnum + "H" # e_shentsize + "H" # e_shnum + "H" # e_shstrndx + ) + ELF64_PHDR = ("I" # p_type + "I" # p_flags + "Q" # p_offset + "Q" # p_vaddr + "Q" # p_paddr + "Q" # p_filesz + "Q" # p_memsz + "Q" # p_align + ) + + def __init__(self): + super(DumpGuestMemory, self).__init__("dump-guest-memory", + gdb.COMMAND_DATA, + gdb.COMPLETE_FILENAME) + self.uintptr_t = gdb.lookup_type("uintptr_t") + self.elf64_ehdr_le = struct.Struct("<%s" % self.ELF64_EHDR) + self.elf64_phdr_le = struct.Struct("<%s" % self.ELF64_PHDR) + + def int128_get64(self, val): + assert (val["hi"] == 0) + return val["lo"] + + def qtailq_foreach(self, head, field_str): + var_p = head["tqh_first"] + while (var_p != 0): + var = var_p.dereference() + yield var + var_p = var[field_str]["tqe_next"] + + def qemu_get_ram_block(self, ram_addr): + ram_blocks = gdb.parse_and_eval("ram_list.blocks") + for block in self.qtailq_foreach(ram_blocks, "next"): + if (ram_addr - block["offset"] < block["length"]): + return block + raise gdb.GdbError("Bad ram offset %x" % ram_addr) + + def qemu_get_ram_ptr(self, ram_addr): + block = self.qemu_get_ram_block(ram_addr) + return block["host"] + (ram_addr - block["offset"]) + + def memory_region_get_ram_ptr(self, mr): + if (mr["alias"] != 0): + return (self.memory_region_get_ram_ptr(mr["alias"].dereference()) + + mr["alias_offset"]) + return self.qemu_get_ram_ptr(mr["ram_addr"] & self.TARGET_PAGE_MASK) + + def guest_phys_blocks_init(self): + self.guest_phys_blocks = [] + + def guest_phys_blocks_append(self): + print "guest RAM blocks:" + print ("target_start target_end host_addr message " + "count") + print ("---------------- ---------------- ---------------- ------- " + "-----") + + current_map_p = gdb.parse_and_eval("address_space_memory.current_map") + current_map = current_map_p.dereference() + for cur in range(current_map["nr"]): + flat_range = (current_map["ranges"] + cur).dereference() + mr = flat_range["mr"].dereference() + + # we only care about RAM + if (not mr["ram"]): + continue + + section_size = self.int128_get64(flat_range["addr"]["size"]) + target_start = self.int128_get64(flat_range["addr"]["start"]) + target_end = target_start + section_size + host_addr = (self.memory_region_get_ram_ptr(mr) + + flat_range["offset_in_region"]) + predecessor = None + + # find continuity in guest physical address space + if (len(self.guest_phys_blocks) > 0): + predecessor = self.guest_phys_blocks[-1] + predecessor_size = (predecessor["target_end"] - + predecessor["target_start"]) + + # the memory API guarantees monotonically increasing + # traversal + assert (predecessor["target_end"] <= target_start) + + # we want continuity in both guest-physical and + # host-virtual memory + if (predecessor["target_end"] < target_start or + predecessor["host_addr"] + predecessor_size != host_addr): + predecessor = None + + if (predecessor is None): + # isolated mapping, add it to the list + self.guest_phys_blocks.append({"target_start": target_start, + "target_end" : target_end, + "host_addr" : host_addr}) + message = "added" + else: + # expand predecessor until @target_end; predecessor's + # start doesn't change + predecessor["target_end"] = target_end + message = "joined" + + print ("%016x %016x %016x %-7s %5u" % + (target_start, target_end, host_addr.cast(self.uintptr_t), + message, len(self.guest_phys_blocks))) + + def cpu_get_dump_info(self): + # We can't synchronize the registers with KVM post-mortem, and + # the bits in (first_x86_cpu->env.hflags) seem to be stale; they + # may not reflect long mode for example. Hence just assume the + # most common values. This also means that instruction pointer + # etc. will be bogus in the dump, but at least the RAM contents + # should be valid. + self.dump_info = {"d_machine": self.EM_X86_64, + "d_endian" : self.ELFDATA2LSB, + "d_class" : self.ELFCLASS64} + + def encode_elf64_ehdr_le(self): + return self.elf64_ehdr_le.pack( + self.ELFMAG, # e_ident/magic + self.dump_info["d_class"], # e_ident/class + self.dump_info["d_endian"], # e_ident/data + self.EV_CURRENT, # e_ident/version + 0, # e_ident/osabi + "", # e_ident/pad + self.ET_CORE, # e_type + self.dump_info["d_machine"], # e_machine + self.EV_CURRENT, # e_version + 0, # e_entry + self.elf64_ehdr_le.size, # e_phoff + 0, # e_shoff + 0, # e_flags + self.elf64_ehdr_le.size, # e_ehsize + self.elf64_phdr_le.size, # e_phentsize + self.phdr_num, # e_phnum + 0, # e_shentsize + 0, # e_shnum + 0 # e_shstrndx + ) + + def encode_elf64_note_le(self): + return self.elf64_phdr_le.pack(self.PT_NOTE, # p_type + 0, # p_flags + (self.memory_offset - + len(self.note)), # p_offset + 0, # p_vaddr + 0, # p_paddr + len(self.note), # p_filesz + len(self.note), # p_memsz + 0 # p_align + ) + + def encode_elf64_load_le(self, offset, start_hwaddr, range_size): + return self.elf64_phdr_le.pack(self.PT_LOAD, # p_type + 0, # p_flags + offset, # p_offset + 0, # p_vaddr + start_hwaddr, # p_paddr + range_size, # p_filesz + range_size, # p_memsz + 0 # p_align + ) + + def note_init(self, name, desc, type): + # name must include a trailing NUL + namesz = (len(name) + 1 + 3) / 4 * 4 + descsz = (len(desc) + 3) / 4 * 4 + fmt = ("<" # little endian + "I" # n_namesz + "I" # n_descsz + "I" # n_type + "%us" # name + "%us" # desc + % (namesz, descsz)) + self.note = struct.pack(fmt, + len(name) + 1, len(desc), type, name, desc) + + def dump_init(self): + self.guest_phys_blocks_init() + self.guest_phys_blocks_append() + self.cpu_get_dump_info() + # we have no way to retrieve the VCPU status from KVM + # post-mortem + self.note_init("NONE", "EMPTY", 0) + + # Account for PT_NOTE. + self.phdr_num = 1 + + # We should never reach PN_XNUM for paging=false dumps: there's + # just a handful of discontiguous ranges after merging. + self.phdr_num += len(self.guest_phys_blocks) + assert (self.phdr_num < self.PN_XNUM) + + # Calculate the ELF file offset where the memory dump commences: + # + # ELF header + # PT_NOTE + # PT_LOAD: 1 + # PT_LOAD: 2 + # ... + # PT_LOAD: len(self.guest_phys_blocks) + # ELF note + # memory dump + self.memory_offset = (self.elf64_ehdr_le.size + + self.elf64_phdr_le.size * self.phdr_num + + len(self.note)) + + def dump_begin(self, vmcore): + vmcore.write(self.encode_elf64_ehdr_le()) + vmcore.write(self.encode_elf64_note_le()) + running = self.memory_offset + for block in self.guest_phys_blocks: + range_size = block["target_end"] - block["target_start"] + vmcore.write(self.encode_elf64_load_le(running, + block["target_start"], + range_size)) + running += range_size + vmcore.write(self.note) + + def dump_iterate(self, vmcore): + qemu_core = gdb.inferiors()[0] + for block in self.guest_phys_blocks: + cur = block["host_addr"] + left = block["target_end"] - block["target_start"] + print ("dumping range at %016x for length %016x" % + (cur.cast(self.uintptr_t), left)) + while (left > 0): + chunk_size = min(self.TARGET_PAGE_SIZE, left) + chunk = qemu_core.read_memory(cur, chunk_size) + vmcore.write(chunk) + cur += chunk_size + left -= chunk_size + + def create_vmcore(self, filename): + vmcore = open(filename, "wb") + self.dump_begin(vmcore) + self.dump_iterate(vmcore) + vmcore.close() + + def invoke(self, args, from_tty): + # Unwittingly pressing the Enter key after the command should + # not dump the same multi-gig coredump to the same file. + self.dont_repeat() + + argv = gdb.string_to_argv(args) + if (len(argv) != 1): + raise gdb.GdbError("usage: dump-guest-memory FILE") + + self.dump_init() + self.create_vmcore(argv[0]) + +DumpGuestMemory()
Signature · 1 line
MST
[Qemu-devel] [PULL 02/29] Add DSDT node for AppleSMC
In reply to Michael S. TsirkinFrom: "Gabriel L. Somlo" <[email protected]>
AppleSMC (-device isa-applesmc) is required to boot OS X guests. OS X expects a SMC node to be present in the ACPI DSDT. This patch adds a SMC node to the DSDT, and dynamically patches the return value of SMC._STA to either 0x0B if the chip is present, or otherwise to 0x00, before booting the guest.
--- include/hw/isa/isa.h | 7 +++++++ hw/i386/acpi-build.c | 9 +++++++++ hw/misc/applesmc.c | 1 - hw/i386/acpi-dsdt-isa.dsl | 11 +++++++++++ hw/i386/acpi-dsdt.dsl | 1 + hw/i386/q35-acpi-dsdt.dsl | 1 + 6 files changed, 29 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +7 -0
@@ -20,6 +20,13 @@#define TYPE_ISA_BUS "ISA"#define ISA_BUS (obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS) +#define TYPE_APPLE_SMC "isa-applesmc" + +static inline bool applesmc_find (void ) +{ +return object_resolve_path_type ("" ,TYPE_APPLE_SMC ,NULL ); +} +typedef struct ISADeviceClass {DeviceClass parent_class; }ISADeviceClass ;
hw/i386/acpi-build.c +9 -0
@@ -36,6 +36,7 @@#include "hw/nvram/fw_cfg.h" #include "bios-linker-loader.h" #include "hw/loader.h" +#include "hw/isa/isa.h" /* Supported chipsets: */ #include "hw/acpi/piix4.h"
@@ -80,6 +81,7 @@ typedef struct AcpiMiscInfo {static void acpi_get_dsdt (AcpiMiscInfo *info) { +unsigned short applesmc_sta_val, *applesmc_sta_off;Object *piix =piix4_pm_find ();Object *lpc =ich9_lpc_find ();assert (!!piix != !!lpc);
@@ -87,11 +89,18 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)if (piix) { info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_size =sizeof AcpiDsdtAmlCode; + applesmc_sta_off = piix_dsdt_applesmc_sta; }if (lpc) { info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_size =sizeof Q35AcpiDsdtAmlCode; + applesmc_sta_off = q35_dsdt_applesmc_sta; } + +/* Patch in appropriate value for AppleSMC _STA */ + applesmc_sta_val =applesmc_find () ?0x0b :0x00 ; + *(uint16_t *)(info->dsdt_code + *applesmc_sta_off) = +cpu_to_le16 (applesmc_sta_val); } static
hw/misc/applesmc.c +0 -1
@@ -66,7 +66,6 @@ struct AppleSMCData {QLIST_ENTRY (AppleSMCData) node; }; -#define TYPE_APPLE_SMC "isa-applesmc"#define APPLE_SMC (obj) OBJECT_CHECK(AppleSMCState, (obj), TYPE_APPLE_SMC)typedef struct AppleSMCState AppleSMCState ;
hw/i386/acpi-dsdt-isa.dsl +11 -0
@@ -16,6 +16,17 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { + Device (SMC) { + Name(_HID, EisaId("APP0001")) + /* _STA will be patched to 0x0B if AppleSMC is present */ + ACPI_EXTRACT_NAME_WORD_CONST DSDT_APPLESMC_STA + Name(_STA, 0xFF00) + Name(_CRS, ResourceTemplate () { + IO (Decode16, 0x0300, 0x0300, 0x01, 0x20) + IRQNoFlags() { 6 } + }) + } + Device(RTC) { Name(_HID, EisaId("PNP0B00")) Name(_CRS, ResourceTemplate() {
hw/i386/acpi-dsdt.dsl +1 -0
@@ -114,6 +114,7 @@ DefinitionBlock ( } } +#define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta #include "acpi-dsdt-isa.dsl"
hw/i386/q35-acpi-dsdt.dsl +1 -0
@@ -171,6 +171,7 @@ DefinitionBlock ( } } +#define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta #include "acpi-dsdt-isa.dsl"
Signature · 1 line
MST
[Qemu-devel] [PULL 04/29] virtio: Fix return value for dummy function vhost_net_virtqueue_pending
In reply to Michael S. TsirkinFrom: Stefan Weil <[email protected]>
cgcc complains that -ENOSYS is not a good value for 'bool'.
A dummy virtio will never have pending queue entries, so let us return false.
--- hw/net/vhost_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/vhost_net.c +1 -1
@@ -321,7 +321,7 @@ void vhost_net_ack_features(struct vhost_net *net, unsigned features)bool vhost_net_virtqueue_pending (VHostNetState *net,int idx) { -return -ENOSYS ; +return false; } void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
Signature · 1 line
MST
[Qemu-devel] [PULL 03/29] ACPI: Fix AppleSMC _STA size
In reply to Michael S. TsirkinFrom: "Gabriel L. Somlo" <[email protected]>
Minimize the storage used for AppleSMC's _STA (8bit), relying on ASL to implicitly convert it to the officially specified 32bit value.
--- hw/i386/acpi-build.c | 11 +++++------ hw/i386/acpi-dsdt-isa.dsl | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +5 -6
@@ -81,7 +81,7 @@ typedef struct AcpiMiscInfo {static void acpi_get_dsdt (AcpiMiscInfo *info) { -unsigned short applesmc_sta_val, *applesmc_sta_off; +uint16_t *applesmc_sta;Object *piix =piix4_pm_find ();Object *lpc =ich9_lpc_find ();assert (!!piix != !!lpc);
@@ -89,18 +89,17 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)if (piix) { info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_size =sizeof AcpiDsdtAmlCode; - applesmc_sta_off = piix_dsdt_applesmc_sta; + applesmc_sta = piix_dsdt_applesmc_sta; }if (lpc) { info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_size =sizeof Q35AcpiDsdtAmlCode; - applesmc_sta_off = q35_dsdt_applesmc_sta; + applesmc_sta = q35_dsdt_applesmc_sta; }/* Patch in appropriate value for AppleSMC _STA */ - applesmc_sta_val =applesmc_find () ?0x0b :0x00 ; - *(uint16_t *)(info->dsdt_code + *applesmc_sta_off) = -cpu_to_le16 (applesmc_sta_val); + *(uint8_t *)(info->dsdt_code + *applesmc_sta) = +applesmc_find () ?0x0b :0x00 ; } static
hw/i386/acpi-dsdt-isa.dsl +2 -2
@@ -19,8 +19,8 @@ Scope(\_SB.PCI0.ISA) { Device (SMC) { Name(_HID, EisaId("APP0001")) /* _STA will be patched to 0x0B if AppleSMC is present */ - ACPI_EXTRACT_NAME_WORD_CONST DSDT_APPLESMC_STA - Name(_STA, 0xFF00) + ACPI_EXTRACT_NAME_BYTE_CONST DSDT_APPLESMC_STA + Name(_STA, 0xF0) Name(_CRS, ResourceTemplate () { IO (Decode16, 0x0300, 0x0300, 0x01, 0x20) IRQNoFlags() { 6 }
Signature · 1 line
MST
[Qemu-devel] [PULL 05/29] acpi unit-test: add test files
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
Added unit-test's expected aml files to be compared with the actual ACPI tables.
--- tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes tests/acpi-test-data/pc/DSDT | Bin 0 -> 4407 bytes tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes tests/acpi-test-data/pc/SSDT | Bin 0 -> 2104 bytes tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes tests/acpi-test-data/q35/DSDT | Bin 0 -> 7344 bytes tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes tests/acpi-test-data/q35/SSDT | Bin 0 -> 2104 bytes 13 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/acpi-test-data/pc/APIC create mode 100644 tests/acpi-test-data/pc/DSDT create mode 100644 tests/acpi-test-data/pc/FACP create mode 100644 tests/acpi-test-data/pc/FACS create mode 100644 tests/acpi-test-data/pc/HPET create mode 100644 tests/acpi-test-data/pc/SSDT create mode 100644 tests/acpi-test-data/q35/APIC create mode 100644 tests/acpi-test-data/q35/DSDT create mode 100644 tests/acpi-test-data/q35/FACP create mode 100644 tests/acpi-test-data/q35/FACS create mode 100644 tests/acpi-test-data/q35/HPET create mode 100644 tests/acpi-test-data/q35/MCFG create mode 100644 tests/acpi-test-data/q35/SSDT
tests/acpi-test-data/pc/APIC new file binary +0 -0
tests/acpi-test-data/pc/DSDT new file binary +0 -0
tests/acpi-test-data/pc/FACP new file binary +0 -0
tests/acpi-test-data/pc/FACS new file binary +0 -0
tests/acpi-test-data/pc/HPET new file binary +0 -0
tests/acpi-test-data/pc/SSDT new file binary +0 -0
tests/acpi-test-data/q35/APIC new file binary +0 -0
tests/acpi-test-data/q35/DSDT new file binary +0 -0
tests/acpi-test-data/q35/FACP new file binary +0 -0
tests/acpi-test-data/q35/FACS new file binary +0 -0
tests/acpi-test-data/q35/HPET new file binary +0 -0
tests/acpi-test-data/q35/MCFG new file binary +0 -0
tests/acpi-test-data/q35/SSDT new file binary +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL 06/29] configure: added acpi unit-test files
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
Ensure configure will set-up links for the files
if the build is created in other directory.
--- configure | 4 ++++ 1 file changed, 4 insertions(+)
configure +4 -0
@@ -4766,6 +4766,10 @@ for bios_file in \ do FILES="$FILES pc-bios/`basename $bios_file`" done +for test_file in `find $source_path/tests/acpi-test-data -type f` +do + FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`" +done mkdir -p $DIRS for f in $FILES ; do if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
Signature · 1 line
MST
[Qemu-devel] [PULL 07/29] acpi unit-test: compare DSDT and SSDT tables against expected values
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
This test will run only if iasl is installed on the host machine. The test plan:
1. Dumps the ACPI tables as AML on the disk.
2. Runs iasl to disassembly the tables into ASL files.
3. Runs iasl to disassembly the offline AML files into ASL files.
4. Compares the ASL files.
The test runs for both default machine and q35. In case the test fails, it can be easily tweaked to show the differences between the ASL files and understand the issue.
--- tests/acpi-test.c | 261 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 240 insertions(+), 21 deletions(-)
tests/acpi-test.c +240 -21
@@ -18,14 +18,22 @@#include "qemu/compiler.h" #include "hw/i386/acpi-defs.h" +#define MACHINE_PC "pc" +#define MACHINE_Q35 "q35" +/* DSDT and SSDTs format */ typedef struct {AcpiTableHeader header; -uint8_t *aml; -int aml_len; -}AcpiSdtTable ; +gchar *aml;/* aml bytecode from guest */ +gsize aml_len; +gchar *aml_file; +gchar *asl;/* asl code generated from aml */ +gsize asl_len; +gchar *asl_file; +} QEMU_PACKED AcpiSdtTable; typedef struct { + const char *machine; uint32_t rsdp_addr; AcpiRsdpDescriptor rsdp_table; AcpiRsdtDescriptorRev1 rsdt_table;
@@ -33,8 +41,7 @@ typedef struct {AcpiFacsDescriptorRev1 facs_table;uint32_t *rsdt_tables_addr;int rsdt_tables_nr; -AcpiSdtTable dsdt_table; -GArray *ssdt_tables; +GArray *ssdt_tables;/* first is DSDT */ } test_data;#define LOW (x) ((x) & 0xff)
@@ -91,8 +98,10 @@ typedef struct {/* Boot sector code: write SIGNATURE into memory, * then halt. +* Q35 machine requires a minimum 0x7e000 bytes disk. +* (bug or feature?) */ -static uint8_t boot_sector[0x200 ] = { +static uint8_t boot_sector[0x7e000 ] = {/* 7c00: mov $0xdead,%ax */ [0x00 ] =0xb8 , [0x01 ] =LOW (SIGNATURE ),
@@ -117,17 +126,40 @@ static uint8_t boot_sector[0x200] = { };static const char *disk ="tests/acpi-test-disk.raw" ; +static const char *data_dir ="tests/acpi-test-data" ;static void free_test_data (test_data *data) { +AcpiSdtTable *temp;int i; -g_free (data->rsdt_tables_addr); +if (data->rsdt_tables_addr) { +g_free (data->rsdt_tables_addr); + } +for (i =0 ; i < data->ssdt_tables->len; ++i) { -g_free (g_array_index (data->ssdt_tables, AcpiSdtTable, i).aml); + temp = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); +if (temp->aml) { +g_free (temp->aml); + } +if (temp->aml_file) { +if (g_strstr_len (temp->aml_file,-1 ,"aml-" )) { +unlink (temp->aml_file); + } +g_free (temp->aml_file); + } +if (temp->asl) { +g_free (temp->asl); + } +if (temp->asl_file) { +if (g_strstr_len (temp->asl_file,-1 ,"asl-" )) { +unlink (temp->asl_file); + } +g_free (temp->asl_file); + } } +g_array_free (data->ssdt_tables, false); -g_free (data->dsdt_table.aml); }static uint8_t acpi_checksum (const uint8_t *data,int len)
@@ -292,34 +324,207 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)ACPI_READ_ARRAY_PTR (sdt_table->aml, sdt_table->aml_len, addr); checksum =acpi_checksum ((uint8_t *)sdt_table,sizeof (AcpiTableHeader)) + -acpi_checksum (sdt_table->aml, sdt_table->aml_len); +acpi_checksum ((uint8_t *)sdt_table->aml, sdt_table->aml_len);g_assert (!checksum); }static void test_acpi_dsdt_table (test_data *data) { -AcpiSdtTable *dsdt_table = &data->dsdt_table; +AcpiSdtTable dsdt_table;uint32_t addr = data->fadt_table.dsdt; -test_dst_table (dsdt_table, addr); - g_assert_cmphex(dsdt_table->header.signature, ==, ACPI_DSDT_SIGNATURE); +memset (&dsdt_table,0 ,sizeof (dsdt_table)); + data->ssdt_tables =g_array_new (false, true,sizeof (AcpiSdtTable)); + +test_dst_table (&dsdt_table, addr); + g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE); + +/* Place DSDT first */ +g_array_append_val (data->ssdt_tables, dsdt_table); }static void test_acpi_ssdt_tables (test_data *data) { -GArray *ssdt_tables;int ssdt_tables_nr = data->rsdt_tables_nr -1 ;/* fadt is first */ int i; - ssdt_tables =g_array_sized_new (false, true,sizeof (AcpiSdtTable), - ssdt_tables_nr);for (i =0 ; i < ssdt_tables_nr; i++) {AcpiSdtTable ssdt_table; + +memset (&ssdt_table,0 ,sizeof (ssdt_table));uint32_t addr = data->rsdt_tables_addr[i +1 ];/* fadt is first */ test_dst_table (&ssdt_table, addr); -g_array_append_val (ssdt_tables, ssdt_table); +g_array_append_val (data->ssdt_tables, ssdt_table); } - data->ssdt_tables = ssdt_tables; +} + +static bool iasl_installed (void ) +{ +gchar *out =NULL , *out_err =NULL ; +bool ret; + +/* pass 'out' and 'out_err' in order to be redirected */ + ret =g_spawn_command_line_sync ("iasl" , &out, &out_err,NULL ,NULL ); + +if (out_err) { + ret = ret && (out_err[0 ] =='\0' ); +g_free (out_err); + } + +if (out) { +g_free (out); + } + +return ret; +} + +static void dump_aml_files (test_data *data) +{ +AcpiSdtTable *sdt; +GError *error =NULL ; +gint fd; +ssize_t ret; +int i; + +for (i =0 ; i < data->ssdt_tables->len; ++i) { + sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); +g_assert (sdt->aml); + + fd =g_file_open_tmp ("aml-XXXXXX" , &sdt->aml_file, &error); +g_assert_no_error (error); + + ret =qemu_write_full (fd, sdt,sizeof (AcpiTableHeader)); +g_assert (ret ==sizeof (AcpiTableHeader)); + ret =qemu_write_full (fd, sdt->aml, sdt->aml_len); +g_assert (ret == sdt->aml_len); + +close (fd); + } +} + +static void load_asl (GArray *sdts,AcpiSdtTable *sdt) +{ +AcpiSdtTable *temp; +GError *error =NULL ; +GString *command_line =g_string_new ("'iasl' " ); +gint fd; +gchar *out, *out_err; +gboolean ret; +int i; + + fd =g_file_open_tmp ("asl-XXXXXX.dsl" , &sdt->asl_file, &error); +g_assert_no_error (error); +close (fd); + +/* build command line */ +g_string_append_printf (command_line,"-p %s " , sdt->asl_file); +for (i =0 ; i <2 ; ++i) {/* reference DSDT and SSDT */ + temp = &g_array_index (sdts, AcpiSdtTable, i); +g_string_append_printf (command_line,"-e %s " , temp->aml_file); + } +g_string_append_printf (command_line,"-d %s" , sdt->aml_file); + +/* pass 'out' and 'out_err' in order to be redirected */ +g_spawn_command_line_sync (command_line->str, &out, &out_err,NULL , &error); +g_assert_no_error (error); + + ret =g_file_get_contents (sdt->asl_file, (gchar **)&sdt->asl, + &sdt->asl_len, &error); +g_assert (ret); +g_assert_no_error (error); +g_assert (sdt->asl_len); + +g_free (out); +g_free (out_err); +g_string_free (command_line, true); +} + +#define COMMENT_END "*/" +#define DEF_BLOCK "DefinitionBlock (" +#define BLOCK_NAME_END ".aml" + +static GString *normalize_asl (gchar *asl_code) +{ +GString *asl =g_string_new (asl_code); +gchar *comment, *block_name; + +/* strip comments (different generation days) */ + comment =g_strstr_len (asl->str, asl->len,COMMENT_END ); +if (comment) { + asl =g_string_erase (asl,0 , comment +sizeof (COMMENT_END ) - asl->str); + } + +/* strip def block name (it has file path in it) */ +if (g_str_has_prefix (asl->str,DEF_BLOCK )) { + block_name =g_strstr_len (asl->str, asl->len,BLOCK_NAME_END ); +g_assert (block_name); + asl =g_string_erase (asl,0 , + block_name +sizeof (BLOCK_NAME_END ) - asl->str); + } + +return asl; +} + +static GArray *load_expected_aml (test_data *data) +{ +int i; +AcpiSdtTable *sdt; +gchar *aml_file; +GError *error =NULL ; +gboolean ret; + +GArray *exp_ssdt_tables =g_array_new (false, true,sizeof (AcpiSdtTable)); +for (i =0 ; i < data->ssdt_tables->len; ++i) { +AcpiSdtTable exp_sdt; + sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); + +memset (&exp_sdt,0 ,sizeof (exp_sdt)); + exp_sdt.header.signature = sdt->header.signature; + + aml_file =g_strdup_printf ("%s/%s/%.4s" , data_dir, data->machine, + (gchar *)&exp_sdt.header.signature); + exp_sdt.aml_file = aml_file; +g_assert (g_file_test (aml_file,G_FILE_TEST_EXISTS )); + ret =g_file_get_contents (aml_file, &exp_sdt.aml, + &exp_sdt.aml_len, &error); +g_assert (ret); +g_assert_no_error (error); +g_assert (exp_sdt.aml); +g_assert (exp_sdt.aml_len); + +g_array_append_val (exp_ssdt_tables, exp_sdt); + } + +return exp_ssdt_tables; +} + +static void test_acpi_asl (test_data *data) +{ +int i; +AcpiSdtTable *sdt, *exp_sdt; +test_data exp_data; + +memset (&exp_data,0 ,sizeof (exp_data)); + exp_data.ssdt_tables =load_expected_aml (data); +dump_aml_files (data); +for (i =0 ; i < data->ssdt_tables->len; ++i) { +GString *asl, *exp_asl; + + sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); + exp_sdt = &g_array_index (exp_data.ssdt_tables, AcpiSdtTable, i); + +load_asl (data->ssdt_tables, sdt); + asl =normalize_asl (sdt->asl); + +load_asl (exp_data.ssdt_tables, exp_sdt); + exp_asl =normalize_asl (exp_sdt->asl); + +g_assert (!g_strcmp0 (asl->str, exp_asl->str)); +g_string_free (asl, true); +g_string_free (exp_asl, true); + } + +free_test_data (&exp_data); }static void test_acpi_one (const char *params,test_data *data)
@@ -329,10 +534,14 @@ static void test_acpi_one(const char *params, test_data *data)uint8_t signature_high;uint16_t signature;int i; +const char *device ="" ; -memset (data,0 ,sizeof (*data)); - args =g_strdup_printf ("-net none -display none %s %s" , - params ? params :"" , disk); +if (!g_strcmp0 (data->machine,MACHINE_Q35 )) { + device =",id=hd -device ide-hd,drive=hd" ; + } + + args =g_strdup_printf ("-net none -display none %s -drive file=%s%s," , + params ? params :"" , disk, device);qtest_start (args);/* Wait at most 1 minute */
@@ -362,6 +571,10 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_dsdt_table (data);test_acpi_ssdt_tables (data); +if (iasl_installed ()) { +test_acpi_asl (data); + } +qtest_quit (global_qtest);g_free (args); }
@@ -373,8 +586,14 @@ static void test_acpi_tcg(void)/* Supplying -machine accel argument overrides the default (qtest). * This is to make guest actually run. */ +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ;test_acpi_one ("-machine accel=tcg" , &data); +free_test_data (&data); +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; +test_acpi_one ("-machine q35,accel=tcg" , &data);free_test_data (&data); }
Signature · 1 line
MST
[Qemu-devel] [PULL 08/29] configure: add CONFIG_IASL to config-host.h
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
Acpi unit-tests will extract iasl executable
from CONFIG_IASL define.
--- scripts/create_config | 4 ++++ 1 file changed, 4 insertions(+)
scripts/create_config +4 -0
@@ -26,6 +26,10 @@ case $line in # save for the next definitions prefix=${line#*=} ;; + IASL=*) # iasl executable + value=${line#*=} + echo "#define CONFIG_IASL $value" + ;; CONFIG_AUDIO_DRIVERS=*) drivers=${line#*=} echo "#define CONFIG_AUDIO_DRIVERS \\"
Signature · 1 line
MST
[Qemu-devel] [PULL 09/29] acpi unit-test: extract iasl executable from configuration
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
The test checked if iasl is installed by running "iasl" and checking the error output.
It is better to use the iasl executable as appears in configuration.
--- tests/acpi-test.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
tests/acpi-test.c +8 -23
@@ -127,6 +127,11 @@ static uint8_t boot_sector[0x7e000] = {static const char *disk ="tests/acpi-test-disk.raw" ;static const char *data_dir ="tests/acpi-test-data" ; +#ifdef CONFIG_IASL +static const char *iasl =stringify (CONFIG_IASL ); +#else +static const char *iasl; +#endif static void free_test_data (test_data *data) {
@@ -358,26 +363,6 @@ static void test_acpi_ssdt_tables(test_data *data) } } -static bool iasl_installed (void ) -{ -gchar *out =NULL , *out_err =NULL ; -bool ret; - -/* pass 'out' and 'out_err' in order to be redirected */ - ret =g_spawn_command_line_sync ("iasl" , &out, &out_err,NULL ,NULL ); - -if (out_err) { - ret = ret && (out_err[0 ] =='\0' ); -g_free (out_err); - } - -if (out) { -g_free (out); - } - -return ret; -} -static void dump_aml_files (test_data *data) {AcpiSdtTable *sdt;
@@ -406,7 +391,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt) {AcpiSdtTable *temp;GError *error =NULL ; -GString *command_line =g_string_new ("'iasl' " ); +GString *command_line =g_string_new (iasl);gint fd;gchar *out, *out_err;gboolean ret;
@@ -417,7 +402,7 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt)close (fd);/* build command line */ -g_string_append_printf (command_line,"-p %s " , sdt->asl_file); +g_string_append_printf (command_line," -p %s " , sdt->asl_file);for (i =0 ; i <2 ; ++i) {/* reference DSDT and SSDT */ temp = &g_array_index (sdts, AcpiSdtTable, i);g_string_append_printf (command_line,"-e %s " , temp->aml_file);
@@ -571,7 +556,7 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_dsdt_table (data);test_acpi_ssdt_tables (data); -if (iasl_installed ()) { +if (iasl) {test_acpi_asl (data); }
Signature · 1 line
MST
[Qemu-devel] [PULL 10/29] acpi unit-test: added script to rebuild the expected aml files
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
Acpi unit-test will fail every time the acpi tables change. This script rebuild the expected aml files, so the test will pass. It also validates the modifications.
--- tests/acpi-test-data/rebuild-expected-aml.sh | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 tests/acpi-test-data/rebuild-expected-aml.sh
tests/acpi-test-data/rebuild-expected-aml.sh new file +36 -0
@@ -0,0 +1,36 @@ +#! /bin/bash + +# +# Rebuild expected AML files for acpi unit-test +# +# Copyright (c) 2013 Red Hat Inc. +# +# Authors: +# Marcel Apfelbaum <[email protected]> +# +# This work is licensed under the terms of the GNU GPLv2. +# See the COPYING.LIB file in the top-level directory. + +qemu= + +if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then + qemu="x86_64-softmmu/qemu-system-x86_64" +elif [ -e i386-softmmu/qemu-system-i386 ]; then + qemu="i386-softmmu/qemu-system-i386" +else + echo "Run 'make' to build the qemu exectutable!" + echo "Run this script from the build directory." + exit 1; +fi + +if [ ! -e "tests/acpi-test" ]; then + echo "Test: acpi-test is required! Run make check before this script." + echo "Run this script from the build directory." + exit 1; +fi + +TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/acpi-test + +echo "The files were rebuilt and can be added to git." +echo "However, if new files were created, please copy them manually" \ + "to tests/acpi-test-data/pc/ or tests/acpi-test-data/q35/ ."
Signature · 1 line
MST
[Qemu-devel] [PULL 11/29] acpi unit-test: hook to rebuild expected aml files
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
When running the test with TEST_ACPI_REBUILD_AML=y environment variable, the test will rebuild and validate the expected aml files.
--- tests/acpi-test.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
tests/acpi-test.c +25 -5
@@ -13,6 +13,7 @@#include <string.h> #include <stdio.h> #include <glib.h> +#include <glib/gstdio.h> #include "qemu-common.h" #include "libqtest.h" #include "qemu/compiler.h"
@@ -21,6 +22,8 @@#define MACHINE_PC "pc"#define MACHINE_Q35 "q35" +#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" +/* DSDT and SSDTs format */ typedef struct { AcpiTableHeader header;
@@ -363,10 +366,11 @@ static void test_acpi_ssdt_tables(test_data *data) } } -static void dump_aml_files (test_data *data) +static void dump_aml_files (test_data *data,bool rebuild) {AcpiSdtTable *sdt;GError *error =NULL ; +gchar *aml_file =NULL ;gint fd;ssize_t ret;int i;
@@ -375,8 +379,16 @@ static void dump_aml_files(test_data *data) sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i);g_assert (sdt->aml); - fd =g_file_open_tmp ("aml-XXXXXX" , &sdt->aml_file, &error); -g_assert_no_error (error); +if (rebuild) { + aml_file =g_strdup_printf ("%s/%s/%.4s" , data_dir, data->machine, + (gchar *)&sdt->header.signature); + fd =g_open (aml_file,O_WRONLY |O_TRUNC |O_CREAT , +S_IRUSR |S_IWUSR |S_IRGRP |S_IWGRP |S_IROTH ); + }else { + fd =g_file_open_tmp ("aml-XXXXXX" , &sdt->aml_file, &error); +g_assert_no_error (error); + } +g_assert (fd >=0 ); ret =qemu_write_full (fd, sdt,sizeof (AcpiTableHeader));g_assert (ret ==sizeof (AcpiTableHeader));
@@ -384,6 +396,10 @@ static void dump_aml_files(test_data *data)g_assert (ret == sdt->aml_len);close (fd); + +if (aml_file) { +g_free (aml_file); + } } }
@@ -491,7 +507,7 @@ static void test_acpi_asl(test_data *data)memset (&exp_data,0 ,sizeof (exp_data)); exp_data.ssdt_tables =load_expected_aml (data); -dump_aml_files (data); +dump_aml_files (data, false);for (i =0 ; i < data->ssdt_tables->len; ++i) {GString *asl, *exp_asl;
@@ -557,7 +573,11 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_ssdt_tables (data);if (iasl) { -test_acpi_asl (data); +if (getenv (ACPI_REBUILD_EXPECTED_AML )) { +dump_aml_files (data, true); + }else { +test_acpi_asl (data); + } }qtest_quit (global_qtest);
Signature · 1 line
MST
[Qemu-devel] [PULL 12/29] tests: fix acpi to work on bigendian host
In reply to Michael S. TsirkinFrom: Alexey Kardashevskiy <[email protected]>
Double endianness convertion make this test failing on POWERPC machine running in big-endian.
This fixes the test to success on big-endian host.
--- tests/acpi-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/acpi-test.c +3 -3
@@ -61,13 +61,13 @@ typedef struct { field =readb (addr); \break ; \case 2 : \ - field =le16_to_cpu (readw (addr)); \ + field =readw (addr); \break ; \case 4 : \ - field =le32_to_cpu (readl (addr)); \ + field =readl (addr); \break ; \case 8 : \ - field =le64_to_cpu (readq (addr)); \ + field =readq (addr); \break ; \default : \g_assert (false); \
Signature · 1 line
MST
[Qemu-devel] [PULL 13/29] acpi unit-test: renamed ssdt_tables to tables
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
Just a refactoring, ssdt_tables name was confusing as it included other tables as well.
--- tests/acpi-test.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
tests/acpi-test.c +24 -24
@@ -44,7 +44,7 @@ typedef struct {AcpiFacsDescriptorRev1 facs_table;uint32_t *rsdt_tables_addr;int rsdt_tables_nr; -GArray *ssdt_tables;/* first is DSDT */ +GArray *tables; } test_data;#define LOW (x) ((x) & 0xff)
@@ -145,8 +145,8 @@ static void free_test_data(test_data *data)g_free (data->rsdt_tables_addr); } -for (i =0 ; i < data->ssdt_tables->len; ++i) { - temp = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); +for (i =0 ; i < data->tables->len; ++i) { + temp = &g_array_index (data->tables, AcpiSdtTable, i);if (temp->aml) {g_free (temp->aml); }
@@ -167,7 +167,7 @@ static void free_test_data(test_data *data) } } -g_array_free (data->ssdt_tables, false); +g_array_free (data->tables, false); }static uint8_t acpi_checksum (const uint8_t *data,int len)
@@ -342,27 +342,27 @@ static void test_acpi_dsdt_table(test_data *data)uint32_t addr = data->fadt_table.dsdt;memset (&dsdt_table,0 ,sizeof (dsdt_table)); - data->ssdt_tables =g_array_new (false, true,sizeof (AcpiSdtTable)); + data->tables =g_array_new (false, true,sizeof (AcpiSdtTable));test_dst_table (&dsdt_table, addr); g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE);/* Place DSDT first */ -g_array_append_val (data->ssdt_tables, dsdt_table); +g_array_append_val (data->tables, dsdt_table); } -static void test_acpi_ssdt_tables (test_data *data) +static void test_acpi_tables (test_data *data) { -int ssdt_tables_nr = data->rsdt_tables_nr -1 ;/* fadt is first */ +int tables_nr = data->rsdt_tables_nr -1 ;/* fadt is first */ int i; -for (i =0 ; i < ssdt_tables_nr; i++) { +for (i =0 ; i < tables_nr; i++) {AcpiSdtTable ssdt_table;memset (&ssdt_table,0 ,sizeof (ssdt_table));uint32_t addr = data->rsdt_tables_addr[i +1 ];/* fadt is first */ test_dst_table (&ssdt_table, addr); -g_array_append_val (data->ssdt_tables, ssdt_table); +g_array_append_val (data->tables, ssdt_table); } }
@@ -375,8 +375,8 @@ static void dump_aml_files(test_data *data, bool rebuild)ssize_t ret;int i; -for (i =0 ; i < data->ssdt_tables->len; ++i) { - sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); +for (i =0 ; i < data->tables->len; ++i) { + sdt = &g_array_index (data->tables, AcpiSdtTable, i);g_assert (sdt->aml);if (rebuild) {
@@ -474,10 +474,10 @@ static GArray *load_expected_aml(test_data *data)GError *error =NULL ;gboolean ret; -GArray *exp_ssdt_tables =g_array_new (false, true,sizeof (AcpiSdtTable)); -for (i =0 ; i < data->ssdt_tables->len; ++i) { +GArray *exp_tables =g_array_new (false, true,sizeof (AcpiSdtTable)); +for (i =0 ; i < data->tables->len; ++i) {AcpiSdtTable exp_sdt; - sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); + sdt = &g_array_index (data->tables, AcpiSdtTable, i);memset (&exp_sdt,0 ,sizeof (exp_sdt)); exp_sdt.header.signature = sdt->header.signature;
@@ -493,10 +493,10 @@ static GArray *load_expected_aml(test_data *data)g_assert (exp_sdt.aml);g_assert (exp_sdt.aml_len); -g_array_append_val (exp_ssdt_tables, exp_sdt); +g_array_append_val (exp_tables, exp_sdt); } -return exp_ssdt_tables; +return exp_tables; }static void test_acpi_asl (test_data *data)
@@ -506,18 +506,18 @@ static void test_acpi_asl(test_data *data)test_data exp_data;memset (&exp_data,0 ,sizeof (exp_data)); - exp_data.ssdt_tables =load_expected_aml (data); + exp_data.tables =load_expected_aml (data);dump_aml_files (data, false); -for (i =0 ; i < data->ssdt_tables->len; ++i) { +for (i =0 ; i < data->tables->len; ++i) {GString *asl, *exp_asl; - sdt = &g_array_index (data->ssdt_tables, AcpiSdtTable, i); - exp_sdt = &g_array_index (exp_data.ssdt_tables, AcpiSdtTable, i); + sdt = &g_array_index (data->tables, AcpiSdtTable, i); + exp_sdt = &g_array_index (exp_data.tables, AcpiSdtTable, i); -load_asl (data->ssdt_tables, sdt); +load_asl (data->tables, sdt); asl =normalize_asl (sdt->asl); -load_asl (exp_data.ssdt_tables, exp_sdt); +load_asl (exp_data.tables, exp_sdt); exp_asl =normalize_asl (exp_sdt->asl);g_assert (!g_strcmp0 (asl->str, exp_asl->str));
@@ -570,7 +570,7 @@ static void test_acpi_one(const char *params, test_data *data)test_acpi_fadt_table (data);test_acpi_facs_table (data);test_acpi_dsdt_table (data); -test_acpi_ssdt_tables (data); +test_acpi_tables (data);if (iasl) {if (getenv (ACPI_REBUILD_EXPECTED_AML )) {
Signature · 1 line
MST
[Qemu-devel] [PULL 14/29] acpi unit-test: resolved iasl crash
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
It seems that iasl has an issue when disassembles some ACPI tables using the command line:
iasl -e DSDT -e SSDT -d HPET
Modified the iasl command line to "iasl -d HPET" until the problem is solved. The command line remained the same for DSDT and SSDT tables.
--- tests/acpi-test.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tests/acpi-test.c +15 -3
@@ -23,6 +23,7 @@#define MACHINE_Q35 "q35"#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" +#define ACPI_SSDT_SIGNATURE 0x54445353/* SSDT */ /* DSDT and SSDTs format */ typedef struct {
@@ -403,6 +404,11 @@ static void dump_aml_files(test_data *data, bool rebuild) } } +static bool compare_signature (AcpiSdtTable *sdt,uint32_t signature) +{ +return sdt->header.signature == signature; +} +static void load_asl (GArray *sdts,AcpiSdtTable *sdt) {AcpiSdtTable *temp;
@@ -419,9 +425,15 @@ static void load_asl(GArray *sdts, AcpiSdtTable *sdt)/* build command line */ g_string_append_printf (command_line," -p %s " , sdt->asl_file); -for (i =0 ; i <2 ; ++i) {/* reference DSDT and SSDT */ - temp = &g_array_index (sdts, AcpiSdtTable, i); -g_string_append_printf (command_line,"-e %s " , temp->aml_file); +if (compare_signature (sdt,ACPI_DSDT_SIGNATURE ) || +compare_signature (sdt,ACPI_SSDT_SIGNATURE )) { +for (i =0 ; i < sdts->len; ++i) { + temp = &g_array_index (sdts, AcpiSdtTable, i); +if (compare_signature (temp,ACPI_DSDT_SIGNATURE ) || +compare_signature (temp,ACPI_SSDT_SIGNATURE )) { +g_string_append_printf (command_line,"-e %s " , temp->aml_file); + } + } }g_string_append_printf (command_line,"-d %s" , sdt->aml_file);
Signature · 1 line
MST
[Qemu-devel] [PULL 15/29] acpi unit-test: do not fail on asl mismatch
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
The asl comparison will break every time the ACPI tables are updated. This may break the git bisect. Instead of failing print a warning on stderr including the retained asl files, so they can be compared offline.
--- tests/acpi-test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tests/acpi-test.c +11 -2
@@ -34,6 +34,7 @@ typedef struct {gchar *asl;/* asl code generated from aml */ gsize asl_len;gchar *asl_file; +bool asl_file_retain;/* do not delete the temp asl */ }QEMU_PACKED AcpiSdtTable; typedef struct {
@@ -161,7 +162,7 @@ static void free_test_data(test_data *data)g_free (temp->asl); }if (temp->asl_file) { -if (g_strstr_len (temp->asl_file,-1 ,"asl-" )) { +if (!temp->asl_file_retain) {unlink (temp->asl_file); }g_free (temp->asl_file);
@@ -532,7 +533,15 @@ static void test_acpi_asl(test_data *data)load_asl (exp_data.tables, exp_sdt); exp_asl =normalize_asl (exp_sdt->asl); -g_assert (!g_strcmp0 (asl->str, exp_asl->str)); +if (g_strcmp0 (asl->str, exp_asl->str)) { + sdt->asl_file_retain = true; + exp_sdt->asl_file_retain = true; +fprintf (stderr, +"acpi-test: Warning! %.4s mismatch. " +"Orig asl: %s, expected asl %s.\n" , + (gchar *)&exp_sdt->header.signature, + sdt->asl_file, exp_sdt->asl_file); + }g_string_free (asl, true);g_string_free (exp_asl, true); }
Signature · 1 line
MST
[Qemu-devel] [PULL 16/29] pc: make: fix dependencies: rebuild when included file is changed
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
some *.dsl files include another *.dsl files but there weren't any dependicies and when included file changed target table wasn't rebuild. Fix this by using the same auto dependency generation as for C files.
--- hw/i386/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/Makefile.objs +1 -1
@@ -17,7 +17,7 @@ iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ 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, cpp -P $(QEMU_DGFLAGS) $< -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, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, " ACPI_EXTRACT $(TARGET_DIR)$*.off")
Signature · 1 line
MST
[Qemu-devel] [PULL 17/29] pci: add pci_for_each_bus_depth_first
In reply to Michael S. TsirkinUseful for ACPI hotplug.
--- include/hw/pci/pci.h | 14 ++++++++++++++ hw/pci/pci.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)
include/hw/pci/pci.h +14 -0
@@ -387,6 +387,20 @@ int pci_bus_num(PCIBus *s);void pci_for_each_device (PCIBus *bus,int bus_num,void (*fn)(PCIBus *bus,PCIDevice *d,void *opaque),void *opaque); +void pci_for_each_bus_depth_first (PCIBus *bus, +void *(*begin)(PCIBus *bus,void *parent_state), +void (*end)(PCIBus *bus,void *state), +void *parent_state); + +/* Use this wrapper when specific scan order is not required. */ +static inline +void pci_for_each_bus (PCIBus *bus, +void (*fn)(PCIBus *bus,void *opaque), +void *opaque) +{ +pci_for_each_bus_depth_first (bus,NULL , fn, opaque); +} +PCIBus *pci_find_primary_bus (void );PCIBus *pci_device_root_bus (const PCIDevice *d);const char *pci_root_bus_path (PCIDevice *dev);
hw/pci/pci.c +28 -0
@@ -1704,6 +1704,34 @@ static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num)return NULL ; } +void pci_for_each_bus_depth_first (PCIBus *bus, +void *(*begin)(PCIBus *bus,void *parent_state), +void (*end)(PCIBus *bus,void *state), +void *parent_state) +{ +PCIBus *sec; +void *state; + +if (!bus) { +return ; + } + +if (begin) { + state =begin (bus, parent_state); + }else { + state = parent_state; + } + + QLIST_FOREACH(sec, &bus->child, sibling) { +pci_for_each_bus_depth_first (sec, begin, end, state); + } + +if (end) { +end (bus, state); + } +} + +PCIDevice *pci_find_device (PCIBus *bus,int bus_num,uint8_t devfn) { bus =pci_find_bus_nr (bus, bus_num);
Signature · 1 line
MST
[Qemu-devel] [PULL 18/29] pcihp: generalization of piix4 acpi
In reply to Michael S. TsirkinAdd ACPI based PCI hotplug library with bridge hotplug support.
Design
- each bus gets assigned "bsel" property.
- ACPI code writes this number
to a new BNUM register, then uses existing UP/DOWN registers to probe slot status; to eject, write number to BNUM register, then slot into existing EJ.
The interface is actually backwards-compatible with existing PIIX4 ACPI (though not migration compatible).
This is split out from PIIX4 codebase so we can
reuse it for Q35 as well.
--- include/hw/acpi/pcihp.h | 72 +++++++++++ hw/acpi/pcihp.c | 316 ++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/Makefile.objs | 3 +- 3 files changed, 389 insertions(+), 2 deletions(-) create mode 100644 include/hw/acpi/pcihp.h create mode 100644 hw/acpi/pcihp.c
include/hw/acpi/pcihp.h new file +72 -0
@@ -0,0 +1,72 @@ +/* +* QEMU<->ACPI BIOS PCI hotplug interface +* +* QEMU supports PCI hotplug via ACPI. This module +* implements the interface between QEMU and the ACPI BIOS. +* Interface specification - see docs/specs/acpi_pci_hotplug.txt +* +* Copyright (c) 2013, Red Hat Inc, Michael S. Tsirkin ([email protected]) +* Copyright (c) 2006 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2 as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/> +* +* Contributions after 2012-01-13 are licensed under the terms of the +* GNU GPL, version 2 or (at your option) any later version. +*/ + +#ifndef HW_ACPI_PCIHP_H +#define HW_ACPI_PCIHP_H + +#include <inttypes.h> +#include <qemu/typedefs.h> +#include "hw/pci/pci.h" /* for PCIHotplugState */ + +typedef struct AcpiPciHpPciStatus { +uint32_t up;/* deprecated, maintained for migration compatibility */ +uint32_t down; +uint32_t hotplug_enable; +uint32_t device_present; +}AcpiPciHpPciStatus ; + +#define ACPI_PCIHP_PROP_BSEL "acpi-pcihp-bsel" +#define ACPI_PCIHP_MAX_HOTPLUG_BUS 256 + +typedef struct AcpiPciHpState { +AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS ]; +uint32_t hotplug_select; +PCIBus *root; +MemoryRegion io; +}AcpiPciHpState ; + +void acpi_pcihp_init (AcpiPciHpState *,PCIBus *root, +MemoryRegion *address_space_io); + +/* Invoke on device hotplug */ +int acpi_pcihp_device_hotplug (AcpiPciHpState *,PCIDevice *, +PCIHotplugState state); + +/* Called on reset */ +void acpi_pcihp_reset (AcpiPciHpState *s); + +extern const VMStateDescription vmstate_acpi_pcihp_pci_status; + +#define VMSTATE_PCI_HOTPLUG (pcihp, state, test_pcihp) \ + VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \ + test_pcihp), \ + VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \ + ACPI_PCIHP_MAX_HOTPLUG_BUS, \ + test_pcihp, 1, \ + vmstate_acpi_pcihp_pci_status, \ + AcpiPciHpPciStatus) + +#endif
hw/acpi/pcihp.c new file +316 -0
316 lines not on this page · raw message
hw/acpi/Makefile.objs +1 -2
@@ -1,2 +1 @@ -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o - +common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o
Signature · 1 line
MST
[Qemu-devel] [PULL 20/29] acpi-build: enable hotplug for PCI bridges
In reply to Michael S. TsirkinThis enables support for device hotplug behind
pci bridges. Bridge devices themselves need
to be pre-configured on qemu command line.
Design:
- at machine init time, assign "bsel" property to bridges with hotplug support
- dynamically (At ACPI table read) generate ACPI code to handle hotplug events for each bridge with "bsel" property
Note: ACPI doesn't support adding or removing bridges by hotplug. We detect and prevent removal of bridges by hotplug, unless they were added by hotplug previously
(and so, are not described by ACPI).
--- hw/i386/acpi-build.c | 346 +++++++++++++++++++++++++++++++++++++++---------- hw/i386/acpi-dsdt.dsl | 34 +++-- hw/i386/ssdt-pcihp.dsl | 11 +- 3 files changed, 297 insertions(+), 94 deletions(-)
hw/i386/acpi-build.c +276 -70
@@ -40,6 +40,7 @@/* Supported chipsets: */ #include "hw/acpi/piix4.h" +#include "hw/acpi/pcihp.h" #include "hw/i386/ich9.h" #include "hw/pci/pci_bus.h" #include "hw/pci-host/q35.h"
@@ -79,6 +80,12 @@ typedef struct AcpiMiscInfo {uint16_t pvpanic_port; } AcpiMiscInfo; +typedef struct AcpiBuildPciBusHotplugState { +GArray *device_table; +GArray *notify_table; +struct AcpiBuildPciBusHotplugState *parent; +}AcpiBuildPciBusHotplugState ; +static void acpi_get_dsdt (AcpiMiscInfo *info) {uint16_t *applesmc_sta;
@@ -179,38 +186,6 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) NULL); } -static void acpi_get_hotplug_info (AcpiMiscInfo *misc) -{ -int i; -PCIBus *bus =find_i440fx (); - -if (!bus) { -/* Only PIIX supports ACPI hotplug */ -memset (misc->slot_hotplug_enable,0 ,sizeof misc->slot_hotplug_enable); -return ; - } - -memset (misc->slot_hotplug_enable,0xff , -DIV_ROUND_UP (PCI_SLOT_MAX ,BITS_PER_BYTE )); - -for (i =0 ; i <ARRAY_SIZE (bus->devices); ++i) { -PCIDeviceClass *pc; -PCIDevice *pdev = bus->devices[i]; - -if (!pdev) { -continue ; - } - - pc =PCI_DEVICE_GET_CLASS (pdev); - -if (pc->no_hotplug) { -int slot =PCI_SLOT (i); - -clear_bit (slot, misc->slot_hotplug_enable); - } - } -} -static void acpi_get_misc_info (AcpiMiscInfo *info) { info->has_hpet =hpet_find ();
@@ -376,6 +351,12 @@ static void build_package(GArray *package, uint8_t op, unsigned min_bytes)build_prepend_byte (package, op); } +static void build_extop_package (GArray *package,uint8_t op) +{ +build_package (package, op,1 ); +build_prepend_byte (package,0x5B );/* ExtOpPrefix */ +} +static void build_append_value (GArray *table,uint32_t value,int size) {uint8_t prefix;
@@ -402,8 +383,44 @@ static void build_append_value(GArray *table, uint32_t value, int size) } } -static void build_append_notify_target (GArray *method,GArray *target_name, -uint32_t value,int size) +static void build_append_int (GArray *table,uint32_t value) +{ +if (value ==0x00 ) { +build_append_byte (table,0x00 );/* ZeroOp */ + }else if (value ==0x01 ) { +build_append_byte (table,0x01 );/* OneOp */ + }else if (value <=0xFF ) { +build_append_value (table, value,1 ); + }else if (value <=0xFFFFF ) { +build_append_value (table, value,2 ); + }else { +build_append_value (table, value,4 ); + } +} + +static GArray *build_alloc_method (const char *name,uint8_t arg_count) +{ +GArray *method =build_alloc_array (); + +build_append_nameseg (method,"%s" , name); +build_append_byte (method, arg_count);/* MethodFlags: ArgCount */ + +return method; +} + +static void build_append_and_cleanup_method (GArray *device,GArray *method) +{ +uint8_t op =0x14 ;/* MethodOp */ + +build_package (method, op,0 ); + +build_append_array (device, method); +build_free_array (method); +} + +static void build_append_notify_target_ifequal (GArray *method, +GArray *target_name, +uint32_t value,int size) {GArray *notify =build_alloc_array ();uint8_t op =0xA0 ;/* IfOp */
@@ -423,6 +440,7 @@ static void build_append_notify_target(GArray *method, GArray *target_name,build_free_array (notify); } +/* End here */ #define ACPI_PORT_SMI_CMD 0x00b2/* TODO: this is APM_CNT_IOPORT */ static inline void *acpi_data_push (GArray *table_data,unsigned size)
@@ -632,44 +650,236 @@ static inline char acpi_get_hex(uint32_t val)#include "hw/i386/ssdt-pcihp.hex" static void -build_append_notify (GArray *device,const char *name, -const char *format,int skip,int count) +build_append_notify_method (GArray *device,const char *name, +const char *format,int count) {int i; -GArray *method =build_alloc_array (); -uint8_t op =0x14 ;/* MethodOp */ +GArray *method =build_alloc_method (name,2 ); -build_append_nameseg (method,"%s" , name); -build_append_byte (method,0x02 );/* MethodFlags: ArgCount */ -for (i = skip; i < count; i++) { +for (i =0 ; i < count; i++) {GArray *target =build_alloc_array ();build_append_nameseg (target, format, i);assert (i <256 );/* Fits in 1 byte */ -build_append_notify_target (method, target, i,1 ); +build_append_notify_target_ifequal (method, target, i,1 );build_free_array (target); } -build_package (method, op,2 ); -build_append_array (device, method); -build_free_array (method); +build_append_and_cleanup_method (device, method); } -static void patch_pcihp (int slot,uint8_t *ssdt_ptr,uint32_t eject) +static void patch_pcihp (int slot,uint8_t *ssdt_ptr) { - ssdt_ptr[ACPI_PCIHP_OFFSET_HEX ] =acpi_get_hex (slot >>4 ); - ssdt_ptr[ACPI_PCIHP_OFFSET_HEX +1 ] =acpi_get_hex (slot); +unsigned devfn =PCI_DEVFN (slot,0 ); + + ssdt_ptr[ACPI_PCIHP_OFFSET_HEX ] =acpi_get_hex (devfn >>4 ); + ssdt_ptr[ACPI_PCIHP_OFFSET_HEX +1 ] =acpi_get_hex (devfn); ssdt_ptr[ACPI_PCIHP_OFFSET_ID ] = slot; ssdt_ptr[ACPI_PCIHP_OFFSET_ADR +2 ] = slot; +} + +/* Assign BSEL property to all buses. In the future, this can be changed +* to only assign to buses that support hotplug. +*/ +static void *acpi_set_bsel (PCIBus *bus,void *opaque) +{ +unsigned *bsel_alloc = opaque; +unsigned *bus_bsel; + +if (bus->qbus.allow_hotplug) { + bus_bsel =g_malloc (sizeof *bus_bsel); + + *bus_bsel = (*bsel_alloc)++; +object_property_add_uint32_ptr (OBJECT (bus),ACPI_PCIHP_PROP_BSEL , + bus_bsel,NULL ); + } + +return bsel_alloc; +} + +static void acpi_set_pci_info (void ) +{ +PCIBus *bus =find_i440fx ();/* TODO: Q35 support */ +unsigned bsel_alloc =0 ; + +if (bus) { +/* Scan all PCI buses. Set property to enable acpi based hotplug. */ +pci_for_each_bus_depth_first (bus, acpi_set_bsel,NULL , &bsel_alloc); + } +} + +static void build_pci_bus_state_init (AcpiBuildPciBusHotplugState *state, +AcpiBuildPciBusHotplugState *parent) +{ + state->parent = parent; + state->device_table =build_alloc_array (); + state->notify_table =build_alloc_array (); +} + +static void build_pci_bus_state_cleanup (AcpiBuildPciBusHotplugState *state) +{ +build_free_array (state->device_table); +build_free_array (state->notify_table); +} + +static void *build_pci_bus_begin (PCIBus *bus,void *parent_state) +{ +AcpiBuildPciBusHotplugState *parent = parent_state; +AcpiBuildPciBusHotplugState *child =g_malloc (sizeof *child); + +build_pci_bus_state_init (child, parent); + +return child; +} + +static void build_pci_bus_end (PCIBus *bus,void *bus_state) +{ +AcpiBuildPciBusHotplugState *child = bus_state; +AcpiBuildPciBusHotplugState *parent = child->parent; +GArray *bus_table =build_alloc_array (); +DECLARE_BITMAP (slot_hotplug_enable,PCI_SLOT_MAX ); +uint8_t op; +int i; +QObject *bsel; +GArray *method; +bool bus_hotplug_support = false; + +if (bus->parent_dev) { + op =0x82 ;/* DeviceOp */ +build_append_nameseg (bus_table,"S%.02X_" , + bus->parent_dev->devfn); +build_append_byte (bus_table,0x08 );/* NameOp */ +build_append_nameseg (bus_table,"_SUN" ); +build_append_value (bus_table,PCI_SLOT (bus->parent_dev->devfn),1 ); +build_append_byte (bus_table,0x08 );/* NameOp */ +build_append_nameseg (bus_table,"_ADR" ); +build_append_value (bus_table, (PCI_SLOT (bus->parent_dev->devfn) <<16 ) | +PCI_FUNC (bus->parent_dev->devfn),4 ); + }else { + op =0x10 ;/* ScopeOp */ ; +build_append_nameseg (bus_table,"PCI0" ); + } -/* Runtime patching of ACPI_EJ0: to disable hotplug for a slot, -* replace the method name: _EJ0 by ACPI_EJ0_. + bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); +if (bsel) { +build_append_byte (bus_table,0x08 );/* NameOp */ +build_append_nameseg (bus_table,"BSEL" ); +build_append_int (bus_table,qint_get_int (qobject_to_qint (bsel))); + +memset (slot_hotplug_enable,0xff ,sizeof slot_hotplug_enable); + +for (i =0 ; i <ARRAY_SIZE (bus->devices); ++i) { +PCIDeviceClass *pc; +PCIDevice *pdev = bus->devices[i]; + +if (!pdev) { +continue ; + } + + pc =PCI_DEVICE_GET_CLASS (pdev); + +if (pc->no_hotplug || pc->is_bridge) { +int slot =PCI_SLOT (i); + +clear_bit (slot, slot_hotplug_enable); + } + } + +/* Append Device object for each slot which supports eject */ +for (i =0 ; i <PCI_SLOT_MAX ; i++) { +bool can_eject =test_bit (i, slot_hotplug_enable); +if (can_eject) { +void *pcihp =acpi_data_push (bus_table, +ACPI_PCIHP_SIZEOF ); +memcpy (pcihp,ACPI_PCIHP_AML ,ACPI_PCIHP_SIZEOF ); +patch_pcihp (i, pcihp); + bus_hotplug_support = true; + } + } + + method =build_alloc_method ("DVNT" ,2 ); + +for (i =0 ; i <PCI_SLOT_MAX ; i++) { +GArray *notify; +uint8_t op; + +if (!test_bit (i, slot_hotplug_enable)) { +continue ; + } + + notify =build_alloc_array (); + op =0xA0 ;/* IfOp */ + +build_append_byte (notify,0x7B );/* AndOp */ +build_append_byte (notify,0x68 );/* Arg0Op */ +build_append_int (notify,0x1 << i); +build_append_byte (notify,0x00 );/* NullName */ +build_append_byte (notify,0x86 );/* NotifyOp */ +build_append_nameseg (notify,"S%.02X_" ,PCI_DEVFN (i,0 )); +build_append_byte (notify,0x69 );/* Arg1Op */ + +/* Pack it up */ +build_package (notify, op,0 ); + +build_append_array (method, notify); + +build_free_array (notify); + } + +build_append_and_cleanup_method (bus_table, method); + } + +/* Append PCNT method to notify about events on local and child buses. +* Add unconditionally for root since DSDT expects it. */ -/* Sanity check */ -assert (!memcmp (ssdt_ptr +ACPI_PCIHP_OFFSET_EJ0 ,"_EJ0" ,4 )); +if (bus_hotplug_support || child->notify_table->len || !bus->parent_dev) { + method =build_alloc_method ("PCNT" ,0 ); + +/* If bus supports hotplug select it and notify about local events */ +if (bsel) { +build_append_byte (method,0x70 );/* StoreOp */ +build_append_int (method,qint_get_int (qobject_to_qint (bsel))); +build_append_nameseg (method,"BNUM" ); +build_append_nameseg (method,"DVNT" ); +build_append_nameseg (method,"PCIU" ); +build_append_int (method,1 );/* Device Check */ +build_append_nameseg (method,"DVNT" ); +build_append_nameseg (method,"PCID" ); +build_append_int (method,3 );/* Eject Request */ + } + +/* Notify about child bus events in any case */ +build_append_array (method, child->notify_table); + +build_append_and_cleanup_method (bus_table, method); + +/* Append description of child buses */ +build_append_array (bus_table, child->device_table); + +/* Pack it up */ +if (bus->parent_dev) { +build_extop_package (bus_table, op); + }else { +build_package (bus_table, op,0 ); + } -if (!eject) { -memcpy (ssdt_ptr +ACPI_PCIHP_OFFSET_EJ0 ,"EJ0_" ,4 ); +/* Append our bus description to parent table */ +build_append_array (parent->device_table, bus_table); + +/* Also tell parent how to notify us, invoking PCNT method. +* At the moment this is not needed for root as we have a single root. +*/ +if (bus->parent_dev) { +build_append_byte (parent->notify_table,'^' );/* ParentPrefixChar */ +build_append_byte (parent->notify_table,0x2E );/* DualNamePrefix */ +build_append_nameseg (parent->notify_table,"S%.02X_" , + bus->parent_dev->devfn); +build_append_nameseg (parent->notify_table,"PCNT" ); + } } + +build_free_array (bus_table); +build_pci_bus_state_cleanup (child); +g_free (child); }static void patch_pci_windows (PcPciInfo *pci,uint8_t *start,unsigned size)
@@ -741,7 +951,7 @@ build_ssdt(GArray *table_data, GArray *linker,* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ -build_append_notify (sb_scope,"NTFY" ,"CP%0.02X" ,0 , acpi_cpus); +build_append_notify_method (sb_scope,"NTFY" ,"CP%0.02X" , acpi_cpus);/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" */ build_append_byte (sb_scope,0x08 );/* NameOp */
@@ -763,24 +973,19 @@ build_ssdt(GArray *table_data, GArray *linker, } { -GArray *pci0 =build_alloc_array (); -uint8_t op =0x10 ;/* ScopeOp */ ; +AcpiBuildPciBusHotplugState hotplug_state; +PCIBus *bus =find_i440fx ();/* TODO: Q35 support */ -build_append_nameseg (pci0,"PCI0" ); +build_pci_bus_state_init (&hotplug_state,NULL ); -/* build Device object for each slot */ -for (i =1 ; i <PCI_SLOT_MAX ; i++) { -bool eject =test_bit (i, misc->slot_hotplug_enable); -void *pcihp =acpi_data_push (pci0,ACPI_PCIHP_SIZEOF ); - -memcpy (pcihp,ACPI_PCIHP_AML ,ACPI_PCIHP_SIZEOF ); -patch_pcihp (i, pcihp, eject); +if (bus) { +/* Scan all PCI buses. Generate tables to support hotplug. */ +pci_for_each_bus_depth_first (bus, build_pci_bus_begin, + build_pci_bus_end, &hotplug_state); } -build_append_notify (pci0,"PCNT" ,"S%0.02X_" ,1 ,PCI_SLOT_MAX ); -build_package (pci0, op,3 ); -build_append_array (sb_scope, pci0); -build_free_array (pci0); +build_append_array (sb_scope, hotplug_state.device_table); +build_pci_bus_state_cleanup (&hotplug_state); }build_package (sb_scope, op,3 );
@@ -1063,7 +1268,6 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_get_cpu_info (&cpu);acpi_get_pm_info (&pm);acpi_get_dsdt (&misc); -acpi_get_hotplug_info (&misc);acpi_get_misc_info (&misc);acpi_get_pci_info (&pci);
@@ -1208,6 +1412,8 @@ void acpi_setup(PcGuestInfo *guest_info) build_state->guest_info = guest_info; +acpi_set_pci_info (); +acpi_build_tables_init (&tables);acpi_build (build_state->guest_info, &tables);
hw/i386/acpi-dsdt.dsl +16 -18
@@ -134,32 +134,28 @@ DefinitionBlock ( B0EJ, 32, } + OperationRegion(BNMR, SystemIO, 0xae10, 0x04) + Field(BNMR, DWordAcc, NoLock, WriteAsZeros) { + BNUM, 32, + } + + /* Lock to protect access to fields above. */ + Mutex(BLCK, 0) + /* Methods called by bulk generated PCI devices below */ /* Methods called by hotplug devices */ - Method(PCEJ, 1, NotSerialized) { + Method(PCEJ, 2, NotSerialized) { // _EJ0 method - eject callback - Store(ShiftLeft(1, Arg0), B0EJ) + Acquire(BLCK, 0xFFFF) + Store(Arg0, BNUM) + Store(ShiftLeft(1, Arg1), B0EJ) + Release(BLCK) Return (0x0) } /* Hotplug notification method supplied by SSDT */ External(\_SB.PCI0.PCNT, MethodObj) - - /* PCI hotplug notify method */ - Method(PCNF, 0) { - // Local0 = iterator - Store(Zero, Local0) - While (LLess(Local0, 31)) { - Increment(Local0) - If (And(PCIU, ShiftLeft(1, Local0))) { - PCNT(Local0, 1) - } - If (And(PCID, ShiftLeft(1, Local0))) { - PCNT(Local0, 3) - } - } - } }
@@ -308,7 +304,9 @@ DefinitionBlock ( } Method(_E01) { // PCI hotplug event - \_SB.PCI0.PCNF() + Acquire(\_SB.PCI0.BLCK, 0xFFFF) + \_SB.PCI0.PCNT() + Release(\_SB.PCI0.BLCK) } Method(_E02) { // CPU hotplug event
hw/i386/ssdt-pcihp.dsl +5 -6
@@ -25,6 +25,7 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1) /* Objects supplied by DSDT */ External(\_SB.PCI0, DeviceObj) External(\_SB.PCI0.PCEJ, MethodObj) + External(BSEL, IntObj) Scope(\_SB.PCI0) {
@@ -33,19 +34,17 @@ DefinitionBlock ("ssdt-pcihp.aml", "SSDT", 0x01, "BXPC", "BXSSDTPCIHP", 0x1) ACPI_EXTRACT_DEVICE_END ssdt_pcihp_end ACPI_EXTRACT_DEVICE_STRING ssdt_pcihp_name - // Method _EJ0 can be patched by BIOS to EJ0_ - // at runtime, if the slot is detected to not support hotplug. - // Extract the offset of the address dword and the - // _EJ0 name to allow this patching. + // Extract the offsets of the device name, address dword and the slot + // name byte - we fill them in for each device. Device(SAA) { ACPI_EXTRACT_NAME_BYTE_CONST ssdt_pcihp_id Name(_SUN, 0xAA) ACPI_EXTRACT_NAME_DWORD_CONST ssdt_pcihp_adr Name(_ADR, 0xAA0000) - ACPI_EXTRACT_METHOD_STRING ssdt_pcihp_ej0 Method(_EJ0, 1) { - Return (PCEJ(_SUN)) + PCEJ(BSEL, _SUN) } } + } }
Signature · 1 line
MST
[Qemu-devel] [PULL 24/29] pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 IO range from PCI bus resources
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
.. so that they might not be used by PCI devices.
Note:
Resort to concatenating templates with preprocessor help, because 1.0b spec isn't supporting ConcatenateResTemplate, as result Windows XP fails to execute PCI0._CRS method if ConcatenateResTemplate() is used.
--- hw/i386/acpi-dsdt-pci-crs.dsl | 8 +------- hw/i386/acpi-dsdt.dsl | 32 ++++++++++++++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 8 ++++++++ 3 files changed, 41 insertions(+), 7 deletions(-)
hw/i386/acpi-dsdt-pci-crs.dsl +1 -7
@@ -37,13 +37,7 @@ Scope(\_SB.PCI0) { 0x0000, // Address Translation Offset 0x0CF8, // Address Length ,, , TypeStatic) - WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, - 0x0000, // Address Space Granularity - 0x0D00, // Address Range Minimum - 0xFFFF, // Address Range Maximum - 0x0000, // Address Translation Offset - 0xF300, // Address Length - ,, , TypeStatic) + BOARD_SPECIFIC_PCI_RESOURSES DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, 0x00000000, // Address Space Granularity 0x000A0000, // Address Range Minimum
hw/i386/acpi-dsdt.dsl +32 -0
@@ -35,6 +35,38 @@ DefinitionBlock ( /**************************************************************** * PCI Bus definition ****************************************************************/ +#define BOARD_SPECIFIC_PCI_RESOURSES \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ + 0x0D00, \ + 0xADFF, \ + 0x0000, \ + 0xA100, \ + ,, , TypeStatic) \ + /* 0xae00-0xae0e hole for PCI hotplug, hw/acpi/piix4.c:PCI_HOTPLUG_ADDR */ \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ + 0xAE0F, \ + 0xAEFF, \ + 0x0000, \ + 0x00F1, \ + ,, , TypeStatic) \ + /* 0xaf00-0xaf1f hole for CPU hotplug, hw/acpi/piix4.c:PIIX4_PROC_BASE */ \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ + 0xAF20, \ + 0xAFDF, \ + 0x0000, \ + 0x00C0, \ + ,, , TypeStatic) \ + /* 0xafe0-0xafe3 hole for ACPI.GPE0, hw/acpi/piix4.c:GPE_BASE */ \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ + 0xAFE4, \ + 0xFFFF, \ + 0x0000, \ + 0x501C, \ + ,, , TypeStatic) Scope(\_SB) { Device(PCI0) {
hw/i386/q35-acpi-dsdt.dsl +8 -0
@@ -48,6 +48,14 @@ DefinitionBlock ( /**************************************************************** * PCI Bus definition ****************************************************************/ +#define BOARD_SPECIFIC_PCI_RESOURSES \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ + 0x0D00, \ + 0xFFFF, \ + 0x0000, \ + 0xF300, \ + ,, , TypeStatic) Scope(\_SB) { Device(PCI0) {
Signature · 1 line
MST
[Qemu-devel] [PULL 23/29] pc: set PRST base in DSDT depending on chipset
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 2 +- hw/i386/acpi-dsdt.dsl | 1 + hw/i386/q35-acpi-dsdt.dsl | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -1
@@ -52,7 +52,7 @@ Scope(\_SB) { Sleep(200) } - OperationRegion(PRST, SystemIO, 0xaf00, 32) + OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, 32) Field(PRST, ByteAcc, NoLock, Preserve) { PRS, 256 }
hw/i386/acpi-dsdt.dsl +1 -0
@@ -290,6 +290,7 @@ DefinitionBlock ( } } +#define CPU_STATUS_BASE 0xaf00 #include "acpi-dsdt-cpu-hotplug.dsl"
hw/i386/q35-acpi-dsdt.dsl +1 -0
@@ -405,6 +405,7 @@ DefinitionBlock ( define_gsi_link(GSIH, 0, 0x17) } +#define CPU_STATUS_BASE 0x0CD8 #include "acpi-dsdt-cpu-hotplug.dsl"
Signature · 1 line
MST
[Qemu-devel] [PULL 25/29] pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
... for range defined at hw/acpi/ich9.c:ICH9_PROC_BASE
--- hw/i386/acpi-dsdt-pci-crs.dsl | 7 ------- hw/i386/acpi-dsdt.dsl | 7 +++++++ hw/i386/q35-acpi-dsdt.dsl | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-)
hw/i386/acpi-dsdt-pci-crs.dsl +0 -7
@@ -30,13 +30,6 @@ Scope(\_SB.PCI0) { 0x01, // Address Alignment 0x08, // Address Length ) - WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, - 0x0000, // Address Space Granularity - 0x0000, // Address Range Minimum - 0x0CF7, // Address Range Maximum - 0x0000, // Address Translation Offset - 0x0CF8, // Address Length - ,, , TypeStatic) BOARD_SPECIFIC_PCI_RESOURSES DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, 0x00000000, // Address Space Granularity
hw/i386/acpi-dsdt.dsl +7 -0
@@ -38,6 +38,13 @@ DefinitionBlock ( #define BOARD_SPECIFIC_PCI_RESOURSES \ WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ 0x0000, \ + 0x0000, \ + 0x0CF7, \ + 0x0000, \ + 0x0CF8, \ + ,, , TypeStatic) \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ 0x0D00, \ 0xADFF, \ 0x0000, \
hw/i386/q35-acpi-dsdt.dsl +8 -0
@@ -51,6 +51,14 @@ DefinitionBlock ( #define BOARD_SPECIFIC_PCI_RESOURSES \ WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ 0x0000, \ + 0x0000, \ + 0x0CD7, \ + 0x0000, \ + 0x0CD8, \ + ,, , TypeStatic) \ + /* 0xcd8-0xcf7 hole for CPU hotplug, hw/acpi/ich9.c:ICH9_PROC_BASE */ \ + WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \ + 0x0000, \ 0x0D00, \ 0xFFFF, \ 0x0000, \
Signature · 1 line
MST
[Qemu-devel] [PULL 26/29] pc: ACPI: expose PRST IO range via _CRS
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
.. so OSPM could notice resource conflict if there is any.
--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
hw/i386/acpi-dsdt-cpu-hotplug.dsl +13 -1
@@ -16,6 +16,7 @@ /**************************************************************** * CPU hotplug ****************************************************************/ +#define CPU_HOTPLUG_RESOURCE_DEVICE PRES Scope(\_SB) { /* Objects filled in by run-time generated SSDT */
@@ -52,7 +53,8 @@ Scope(\_SB) { Sleep(200) } - OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, 32) +#define CPU_STATUS_LEN 32 + OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN) Field(PRST, ByteAcc, NoLock, Preserve) { PRS, 256 }
@@ -89,4 +91,14 @@ Scope(\_SB) { Increment(Local0) } } + + Device(CPU_HOTPLUG_RESOURCE_DEVICE) { + Name(_HID, "ACPI0004") + + Name(_CRS, ResourceTemplate() { + IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN) + }) + + Name(_STA, 0xB) /* present, functioning, decoding, not shown in UI */ + } }
Signature · 1 line
MST
[Qemu-devel] [PULL 27/29] pc: ACPI: unify source of CPU hotplug IO base/len
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
use C headers defines as source of IO base/len for respective values in ASL code.
--- include/hw/acpi/cpu_hotplug_defs.h | 1 + hw/acpi/piix4.c | 5 ++--- hw/i386/Makefile.objs | 2 +- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 2 +- hw/i386/acpi-dsdt.dsl | 3 ++- hw/i386/q35-acpi-dsdt.dsl | 3 ++- 6 files changed, 9 insertions(+), 7 deletions(-)
include/hw/acpi/cpu_hotplug_defs.h +1 -0
@@ -19,5 +19,6 @@#define ACPI_CPU_HOTPLUG_STATUS 4#define ACPI_GPE_PROC_LEN 32#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8 +#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#endif
hw/acpi/piix4.c +2 -3
@@ -51,8 +51,6 @@#define PCI_EJ_BASE 0xae08#define PCI_RMV_BASE 0xae0c -#define PIIX4_PROC_BASE 0xaf00 -#define PIIX4_PCI_HOTPLUG_STATUS 2struct pci_status {
@@ -706,7 +704,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); } -AcpiCpuHotplug_init (parent,OBJECT (s), &s->gpe_cpu,PIIX4_PROC_BASE ); +AcpiCpuHotplug_init (parent,OBJECT (s), &s->gpe_cpu, +PIIX4_CPU_HOTPLUG_IO_BASE ); s->cpu_added_notifier.notify = piix4_cpu_added_req;qemu_register_cpu_added_notifier (&s->cpu_added_notifier); }
hw/i386/Makefile.objs +1 -1
@@ -17,7 +17,7 @@ iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ 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 $(QEMU_DGFLAGS) $< -o $*.dsl.i.orig, " CPP $(TARGET_DIR)$*.dsl.i.orig") + $(call quiet-command, cpp -P $(QEMU_DGFLAGS) $(QEMU_INCLUDES) $< -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, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, " ACPI_EXTRACT $(TARGET_DIR)$*.off")
hw/i386/acpi-dsdt-cpu-hotplug.dsl +1 -1
@@ -53,7 +53,7 @@ Scope(\_SB) { Sleep(200) } -#define CPU_STATUS_LEN 32 +#define CPU_STATUS_LEN ACPI_GPE_PROC_LEN OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN) Field(PRST, ByteAcc, NoLock, Preserve) { PRS, 256
hw/i386/acpi-dsdt.dsl +2 -1
@@ -329,7 +329,8 @@ DefinitionBlock ( } } -#define CPU_STATUS_BASE 0xaf00 +#include "hw/acpi/cpu_hotplug_defs.h" +#define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl"
hw/i386/q35-acpi-dsdt.dsl +2 -1
@@ -421,7 +421,8 @@ DefinitionBlock ( define_gsi_link(GSIH, 0, 0x17) } -#define CPU_STATUS_BASE 0x0CD8 +#include "hw/acpi/cpu_hotplug_defs.h" +#define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl"
Signature · 1 line
MST
[Qemu-devel] [PULL 28/29] pc: ACPI: update acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generated
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
--- hw/i386/acpi-dsdt.hex.generated | 217 +++++++++++++++++++++++++----------- hw/i386/q35-acpi-dsdt.hex.generated | 74 ++++++++++-- hw/i386/ssdt-pcihp.hex.generated | 20 ++-- hw/i386/ssdt-proc.hex.generated | 6 +- 4 files changed, 225 insertions(+), 92 deletions(-)
hw/i386/acpi-dsdt.hex.generated +150 -67
@@ -3,12 +3,12 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x53, 0x44, 0x54, -0x37, +0x87, 0x11, 0x0, 0x0, 0x1, -0xd8, +0xb8, 0x42, 0x58, 0x50,
@@ -860,8 +860,8 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x4e, 0x1, 0x10, -0x4c, -0x1b, +0x4b, +0x1e, 0x2f, 0x3, 0x5f,
@@ -879,6 +879,53 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x5b, 0x82, 0x2d, +0x53, +0x4d, +0x43, +0x5f, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x6, +0x10, +0x0, +0x1, +0x8, +0x5f, +0x53, +0x54, +0x41, +0xb, +0x0, +0xff, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x10, +0xa, +0xd, +0x47, +0x1, +0x0, +0x3, +0x0, +0x3, +0x1, +0x20, +0x22, +0x40, +0x0, +0x79, +0x0, +0x5b, +0x82, +0x2d, 0x52, 0x54, 0x43,
@@ -1305,7 +1352,7 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x79, 0x0, 0x10, -0x4b, +0x48, 0x8, 0x2e, 0x5f,
@@ -1371,79 +1418,76 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x45, 0x4a, 0x20, +0x5b, +0x80, +0x42, +0x4e, +0x4d, +0x52, +0x1, +0xb, +0x10, +0xae, +0xa, +0x4, +0x5b, +0x81, +0xb, +0x42, +0x4e, +0x4d, +0x52, +0x43, +0x42, +0x4e, +0x55, +0x4d, +0x20, +0x5b, +0x1, +0x42, +0x4c, +0x43, +0x4b, +0x0, 0x14, -0x11, +0x25, 0x50, 0x43, 0x45, 0x4a, -0x1, +0x2, +0x5b, +0x23, +0x42, +0x4c, +0x43, +0x4b, +0xff, +0xff, 0x70, -0x79, -0x1, 0x68, -0x0, 0x42, -0x30, -0x45, -0x4a, -0xa4, -0x0, -0x14, -0x36, -0x50, -0x43, 0x4e, -0x46, -0x0, -0x70, -0x0, -0x60, -0xa2, -0x2c, -0x95, -0x60, -0xa, -0x1f, -0x75, -0x60, -0xa0, -0x11, -0x7b, -0x50, -0x43, -0x49, 0x55, +0x4d, +0x70, 0x79, 0x1, -0x60, +0x69, 0x0, -0x0, -0x50, -0x43, -0x4e, -0x54, -0x60, -0x1, -0xa0, -0x12, -0x7b, -0x50, +0x42, +0x30, +0x45, +0x4a, +0x5b, +0x27, +0x42, +0x4c, 0x43, -0x49, -0x44, -0x79, -0x1, -0x60, -0x0, +0x4b, +0xa4, 0x0, -0x50, -0x43, -0x4e, -0x54, -0x60, -0xa, -0x3, 0x10, 0x4a, 0xa0,
@@ -4248,8 +4292,8 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x75, 0x60, 0x10, -0x4e, -0x9, +0x42, +0xc, 0x5f, 0x47, 0x50,
@@ -4277,12 +4321,31 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x30, 0x0, 0x14, -0x15, +0x39, 0x5f, 0x45, 0x30, 0x31, 0x0, +0x5b, +0x23, +0x5c, +0x2f, +0x3, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x42, +0x4c, +0x43, +0x4b, +0xff, +0xff, 0x5c, 0x2f, 0x3,
@@ -4297,7 +4360,24 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x50, 0x43, 0x4e, -0x46, +0x54, +0x5b, +0x27, +0x5c, +0x2f, +0x3, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x42, +0x4c, +0x43, +0x4b, 0x14, 0x10, 0x5f,
@@ -4407,3 +4487,6 @@ static unsigned char AcpiDsdtAmlCode[] = { 0x46, 0x0 }; +static unsigned short piix_dsdt_applesmc_sta[] = { +0x384 +};
hw/i386/q35-acpi-dsdt.hex.generated +62 -12
116 lines not on this page · raw message
hw/i386/ssdt-pcihp.hex.generated +10 -10
@@ -5,19 +5,19 @@ static unsigned char ssdt_pcihp_adr[] = { 0x44 }; static unsigned char ssdt_pcihp_end[] = { -0x58 +0x5b }; static unsigned char ssdp_pcihp_aml[] = { 0x53, 0x53, 0x44, 0x54, -0x58, +0x5b, 0x0, 0x0, 0x0, 0x1, -0x76, +0xe8, 0x42, 0x58, 0x50,
@@ -45,7 +45,7 @@ static unsigned char ssdp_pcihp_aml[] = { 0x13, 0x20, 0x10, -0x33, +0x36, 0x5c, 0x2e, 0x5f,
@@ -58,7 +58,7 @@ static unsigned char ssdp_pcihp_aml[] = { 0x30, 0x5b, 0x82, -0x26, +0x29, 0x53, 0x41, 0x41,
@@ -81,17 +81,20 @@ static unsigned char ssdp_pcihp_aml[] = { 0xaa, 0x0, 0x14, -0xf, +0x12, 0x5f, 0x45, 0x4a, 0x30, 0x1, -0xa4, 0x50, 0x43, 0x45, 0x4a, +0x42, +0x53, +0x45, +0x4c, 0x5f, 0x53, 0x55,
@@ -103,6 +106,3 @@ static unsigned char ssdt_pcihp_start[] = { static unsigned char ssdt_pcihp_id[] = { 0x3d }; -static unsigned char ssdt_pcihp_ej0[] = { -0x4a -};
hw/i386/ssdt-proc.hex.generated +3 -3
@@ -11,7 +11,7 @@ static unsigned char ssdp_proc_aml[] = { 0x0, 0x0, 0x1, -0xb8, +0x78, 0x42, 0x58, 0x50,
@@ -47,8 +47,8 @@ static unsigned char ssdp_proc_aml[] = { 0x41, 0x41, 0xaa, -0x10, -0xb0, +0x0, +0x0, 0x0, 0x0, 0x0,
Signature · 1 line
MST
[Qemu-devel] [PULL 29/29] acpi-test: update expected AML since recent changes
In reply to Michael S. Tsirkin--- tests/acpi-test-data/pc/DSDT | Bin 4407 -> 4582 bytes tests/acpi-test-data/pc/SSDT | Bin 2104 -> 2200 bytes tests/acpi-test-data/q35/DSDT | Bin 7344 -> 7438 bytes tests/acpi-test-data/q35/SSDT | Bin 2104 -> 475 bytes 4 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/DSDT binary +0 -0
tests/acpi-test-data/pc/SSDT binary +0 -0
tests/acpi-test-data/q35/DSDT binary +0 -0
tests/acpi-test-data/q35/SSDT binary +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL 19/29] piix4: add acpi pci hotplug support
In reply to Michael S. TsirkinAdd support for acpi pci hotplug using the
new infrastructure.
PIIX4 legacy interface is maintained as is for
machine types 1.6 and older.
--- include/hw/i386/pc.h | 5 ++++ hw/acpi/piix4.c | 75 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 10 deletions(-)
include/hw/i386/pc.h +5 -0
@@ -261,6 +261,11 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);#define PC_COMPAT_1_6 \ {\ + .driver = "PIIX4_PM",\ + .property = "acpi-pci-hotplug-with-bridge-support",\ + .value = "off",\ + }, \ + {\ .driver = "e1000",\ .property = "mitigation",\ .value = "off",\
hw/acpi/piix4.c +65 -10
139 lines not on this page · raw message
Signature · 1 line
MST
Re: [Qemu-devel] [PULL 19/29] piix4: add acpi pci hotplug support
Quoted 4 lines · Michael S. Tsirkin
Add support for acpi pci hotplug using the
new infrastructure.
PIIX4 legacy interface is maintained as is for
machine types 1.6 and older.
Actually that's wrong of course, should be off for 1.7 and older.
I'll send v2.
Quoted 179 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/pc.h | 5 ++++ hw/acpi/piix4.c | 75 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 10 deletions(-)include/hw/i386/pc.h +5
-0@@ -261,6 +261,11 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);#define PC_COMPAT_1_6 \ {\ + .driver = "PIIX4_PM",\ + .property = "acpi-pci-hotplug-with-bridge-support",\ + .value = "off",\ + }, \ + {\ .driver = "e1000",\ .property = "mitigation",\ .value = "off",\hw/acpi/piix4.c +65
-10@@ -30,6 +30,7 @@#include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" #include "hw/acpi/piix4.h" +#include "hw/acpi/pcihp.h" //#define DEBUG @@ -73,7 +74,6 @@ typedef struct PIIX4PMState {uint32_t io_base;MemoryRegion io_gpe; -MemoryRegion io_pci;MemoryRegion io_cpu;ACPIREGS ar;@@ -88,11 +88,16 @@ typedef struct PIIX4PMState {Notifier machine_ready;Notifier powerdown_notifier; -/* for pci hotplug */ +/* for legacy pci hotplug (compatible with qemu 1.6 and older) */ +MemoryRegion io_pci;struct pci_status pci0_status;uint32_t pci0_hotplug_enable;uint32_t pci0_slot_device_present; +/* for new pci hotplug (with PCI2PCI bridge support) */ +AcpiPciHpState acpi_pci_hotplug; +bool use_acpi_pci_hotplug; +uint8_t disable_s3;uint8_t disable_s4;uint8_t s4_val;@@ -263,6 +268,18 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)return ret; } +static bool vmstate_test_use_acpi_pci_hotplug (void *opaque,int version_id) +{ +PIIX4PMState *s = opaque; +return s->use_acpi_pci_hotplug; +} + +static bool vmstate_test_no_use_acpi_pci_hotplug (void *opaque,int version_id) +{ +PIIX4PMState *s = opaque; +return !s->use_acpi_pci_hotplug; +} +/* qemu-kvm 1.2 uses version 3 but advertised as 2 * To support incoming qemu-kvm 1.2 migration, change version_id * and minimum_version_id to 2 below (which breaks migration from @@ -285,8 +302,12 @@ static const VMStateDescription vmstate_acpi = {VMSTATE_TIMER (ar.tmr.timer, PIIX4PMState),VMSTATE_INT64 (ar.tmr.overflow_time, PIIX4PMState),VMSTATE_STRUCT (ar.gpe, PIIX4PMState,2 , vmstate_gpe,ACPIGPE ), -VMSTATE_STRUCT (pci0_status, PIIX4PMState,2 , vmstate_pci_status, - struct pci_status), +VMSTATE_STRUCT_TEST (pci0_status, PIIX4PMState, + vmstate_test_no_use_acpi_pci_hotplug, +2 , vmstate_pci_status, + struct pci_status), +VMSTATE_PCI_HOTPLUG (acpi_pci_hotplug, PIIX4PMState, + vmstate_test_use_acpi_pci_hotplug), VMSTATE_END_OF_LIST() } };@@ -364,7 +385,11 @@ static void piix4_reset(void *opaque) pci_conf[0x5B ] =0x02 ; }pm_io_space_update (s); -piix4_update_hotplug (s); +if (s->use_acpi_pci_hotplug) { +acpi_pcihp_reset (&s->acpi_pci_hotplug); + }else { +piix4_update_hotplug (s); + } }static void piix4_pm_powerdown_req (Notifier *n,void *opaque)@@ -375,6 +400,26 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque)acpi_pm1_evt_power_down (&s->ar); } +static int piix4_acpi_pci_hotplug (DeviceState *qdev,PCIDevice *dev, +PCIHotplugState state) +{ +PIIX4PMState *s =PIIX4_PM (qdev); +int ret =acpi_pcihp_device_hotplug (&s->acpi_pci_hotplug, dev, state); +if (ret <0 ) { +return ret; + } + s->ar.gpe.sts[0 ] |=PIIX4_PCI_HOTPLUG_STATUS ; + +acpi_update_sci (&s->ar, s->irq); +return 0 ; +} + +static void piix4_update_bus_hotplug (PCIBus *bus,void *opaque) +{ +PIIX4PMState *s = opaque; +pci_bus_hotplug (bus, piix4_acpi_pci_hotplug,DEVICE (s)); +} +static void piix4_pm_machine_ready (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, machine_ready);@@ -388,6 +433,10 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) pci_conf[0x63 ] =0x60 ; pci_conf[0x67 ] = (memory_region_present (io_as,0x3f8 ) ?0x08 :0 ) | (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); + +if (s->use_acpi_pci_hotplug) { +pci_for_each_bus (d->bus, piix4_update_bus_hotplug, s); + } }static void piix4_pm_add_propeties (PIIX4PMState *s)@@ -509,6 +558,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S3_DISABLED , PIIX4PMState, disable_s3,0 ),DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_DISABLED , PIIX4PMState, disable_s4,0 ),DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ), +DEFINE_PROP_BOOL ("acpi-pci-hotplug-with-bridge-support" , PIIX4PMState, + use_acpi_pci_hotplug, true), DEFINE_PROP_END_OF_LIST(), };@@ -701,11 +752,15 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN);memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -memory_region_init_io (&s->io_pci,OBJECT (s), &piix4_pci_ops, s, -"acpi-pci-hotplug" ,PCI_HOTPLUG_SIZE ); -memory_region_add_subregion (parent,PCI_HOTPLUG_ADDR , - &s->io_pci); -pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); +if (s->use_acpi_pci_hotplug) { +acpi_pcihp_init (&s->acpi_pci_hotplug, bus, parent); + }else { +memory_region_init_io (&s->io_pci,OBJECT (s), &piix4_pci_ops, s, +"acpi-pci-hotplug" ,PCI_HOTPLUG_SIZE ); +memory_region_add_subregion (parent,PCI_HOTPLUG_ADDR , + &s->io_pci); +pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); + }CPU_FOREACH (cpu) {CPUClass *cc =CPU_GET_CLASS (cpu);Signature · 1 line
MST
Re: [Qemu-devel] [PULL 19/29] piix4: add acpi pci hotplug support
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin
Add support for acpi pci hotplug using the
new infrastructure.
PIIX4 legacy interface is maintained as is for
machine types 1.6 and older.Actually that's wrong of course, should be off for 1.7 and older.
I'll send v2.
Actually seems like it's too painful to do now that everything has been pushed to a public branch. :(
I'll just apply a fix on top.
Quoted 179 lines
Quoted 179 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/pc.h | 5 ++++ hw/acpi/piix4.c | 75 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 10 deletions(-)include/hw/i386/pc.h +5
-0@@ -261,6 +261,11 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);#define PC_COMPAT_1_6 \ {\ + .driver = "PIIX4_PM",\ + .property = "acpi-pci-hotplug-with-bridge-support",\ + .value = "off",\ + }, \ + {\ .driver = "e1000",\ .property = "mitigation",\ .value = "off",\hw/acpi/piix4.c +65
-10@@ -30,6 +30,7 @@#include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" #include "hw/acpi/piix4.h" +#include "hw/acpi/pcihp.h" //#define DEBUG @@ -73,7 +74,6 @@ typedef struct PIIX4PMState {uint32_t io_base;MemoryRegion io_gpe; -MemoryRegion io_pci;MemoryRegion io_cpu;ACPIREGS ar;@@ -88,11 +88,16 @@ typedef struct PIIX4PMState {Notifier machine_ready;Notifier powerdown_notifier; -/* for pci hotplug */ +/* for legacy pci hotplug (compatible with qemu 1.6 and older) */ +MemoryRegion io_pci;struct pci_status pci0_status;uint32_t pci0_hotplug_enable;uint32_t pci0_slot_device_present; +/* for new pci hotplug (with PCI2PCI bridge support) */ +AcpiPciHpState acpi_pci_hotplug; +bool use_acpi_pci_hotplug; +uint8_t disable_s3;uint8_t disable_s4;uint8_t s4_val;@@ -263,6 +268,18 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)return ret; } +static bool vmstate_test_use_acpi_pci_hotplug (void *opaque,int version_id) +{ +PIIX4PMState *s = opaque; +return s->use_acpi_pci_hotplug; +} + +static bool vmstate_test_no_use_acpi_pci_hotplug (void *opaque,int version_id) +{ +PIIX4PMState *s = opaque; +return !s->use_acpi_pci_hotplug; +} +/* qemu-kvm 1.2 uses version 3 but advertised as 2 * To support incoming qemu-kvm 1.2 migration, change version_id * and minimum_version_id to 2 below (which breaks migration from @@ -285,8 +302,12 @@ static const VMStateDescription vmstate_acpi = {VMSTATE_TIMER (ar.tmr.timer, PIIX4PMState),VMSTATE_INT64 (ar.tmr.overflow_time, PIIX4PMState),VMSTATE_STRUCT (ar.gpe, PIIX4PMState,2 , vmstate_gpe,ACPIGPE ), -VMSTATE_STRUCT (pci0_status, PIIX4PMState,2 , vmstate_pci_status, - struct pci_status), +VMSTATE_STRUCT_TEST (pci0_status, PIIX4PMState, + vmstate_test_no_use_acpi_pci_hotplug, +2 , vmstate_pci_status, + struct pci_status), +VMSTATE_PCI_HOTPLUG (acpi_pci_hotplug, PIIX4PMState, + vmstate_test_use_acpi_pci_hotplug), VMSTATE_END_OF_LIST() } };@@ -364,7 +385,11 @@ static void piix4_reset(void *opaque) pci_conf[0x5B ] =0x02 ; }pm_io_space_update (s); -piix4_update_hotplug (s); +if (s->use_acpi_pci_hotplug) { +acpi_pcihp_reset (&s->acpi_pci_hotplug); + }else { +piix4_update_hotplug (s); + } }static void piix4_pm_powerdown_req (Notifier *n,void *opaque)@@ -375,6 +400,26 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque)acpi_pm1_evt_power_down (&s->ar); } +static int piix4_acpi_pci_hotplug (DeviceState *qdev,PCIDevice *dev, +PCIHotplugState state) +{ +PIIX4PMState *s =PIIX4_PM (qdev); +int ret =acpi_pcihp_device_hotplug (&s->acpi_pci_hotplug, dev, state); +if (ret <0 ) { +return ret; + } + s->ar.gpe.sts[0 ] |=PIIX4_PCI_HOTPLUG_STATUS ; + +acpi_update_sci (&s->ar, s->irq); +return 0 ; +} + +static void piix4_update_bus_hotplug (PCIBus *bus,void *opaque) +{ +PIIX4PMState *s = opaque; +pci_bus_hotplug (bus, piix4_acpi_pci_hotplug,DEVICE (s)); +} +static void piix4_pm_machine_ready (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, machine_ready);@@ -388,6 +433,10 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) pci_conf[0x63 ] =0x60 ; pci_conf[0x67 ] = (memory_region_present (io_as,0x3f8 ) ?0x08 :0 ) | (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); + +if (s->use_acpi_pci_hotplug) { +pci_for_each_bus (d->bus, piix4_update_bus_hotplug, s); + } }static void piix4_pm_add_propeties (PIIX4PMState *s)@@ -509,6 +558,8 @@ static Property piix4_pm_properties[] = {DEFINE_PROP_UINT8 (ACPI_PM_PROP_S3_DISABLED , PIIX4PMState, disable_s3,0 ),DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_DISABLED , PIIX4PMState, disable_s4,0 ),DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ), +DEFINE_PROP_BOOL ("acpi-pci-hotplug-with-bridge-support" , PIIX4PMState, + use_acpi_pci_hotplug, true), DEFINE_PROP_END_OF_LIST(), };@@ -701,11 +752,15 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN);memory_region_add_subregion (parent,GPE_BASE , &s->io_gpe); -memory_region_init_io (&s->io_pci,OBJECT (s), &piix4_pci_ops, s, -"acpi-pci-hotplug" ,PCI_HOTPLUG_SIZE ); -memory_region_add_subregion (parent,PCI_HOTPLUG_ADDR , - &s->io_pci); -pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); +if (s->use_acpi_pci_hotplug) { +acpi_pcihp_init (&s->acpi_pci_hotplug, bus, parent); + }else { +memory_region_init_io (&s->io_pci,OBJECT (s), &piix4_pci_ops, s, +"acpi-pci-hotplug" ,PCI_HOTPLUG_SIZE ); +memory_region_add_subregion (parent,PCI_HOTPLUG_ADDR , + &s->io_pci); +pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s)); + }CPU_FOREACH (cpu) {CPUClass *cc =CPU_GET_CLASS (cpu);Signature · 1 line
MST
[Qemu-devel] [PULL 21/29] acpi: factor out common cpu hotplug code for PIIX4/Q35
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
.. so it could be used for adding CPU hotplug to Q35 machine
Add an additional header with that will be shared between C and ASL code: include/hw/acpi/cpu_hotplug_defs.h
--- include/hw/acpi/cpu_hotplug.h | 27 +++++++++++++ include/hw/acpi/cpu_hotplug_defs.h | 22 +++++++++++ hw/acpi/cpu_hotplug.c | 64 +++++++++++++++++++++++++++++++ hw/acpi/piix4.c | 77 +++----------------------------------- hw/acpi/Makefile.objs | 2 +- 5 files changed, 120 insertions(+), 72 deletions(-) create mode 100644 include/hw/acpi/cpu_hotplug.h create mode 100644 include/hw/acpi/cpu_hotplug_defs.h create mode 100644 hw/acpi/cpu_hotplug.c
include/hw/acpi/cpu_hotplug.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* QEMU ACPI hotplug utilities +* +* Copyright (C) 2013 Red Hat Inc +* +* Authors: +* Igor Mammedov <[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. +*/ +#ifndef ACPI_HOTPLUG_H +#define ACPI_HOTPLUG_H + +#include "hw/acpi/acpi.h" +#include "hw/acpi/cpu_hotplug_defs.h" + +typedef struct AcpiCpuHotplug { +MemoryRegion io; +uint8_t sts[ACPI_GPE_PROC_LEN ]; +}AcpiCpuHotplug ; + +void AcpiCpuHotplug_add (ACPIGPE *gpe,AcpiCpuHotplug *g,CPUState *cpu); + +void AcpiCpuHotplug_init (MemoryRegion *parent,Object *owner, +AcpiCpuHotplug *gpe_cpu,uint16_t base); +#endif
include/hw/acpi/cpu_hotplug_defs.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* QEMU ACPI hotplug utilities shared defines +* +* Copyright (C) 2013 Red Hat Inc +* +* Authors: +* Igor Mammedov <[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. +*/ +#ifndef ACPI_HOTPLUG_DEFS_H +#define ACPI_HOTPLUG_DEFS_H + +/* +* ONLY DEFINEs are permited in this file since it's shared +* between C and ASL code. +*/ +#define ACPI_CPU_HOTPLUG_STATUS 4 +#define ACPI_GPE_PROC_LEN 32 + +#endif
hw/acpi/cpu_hotplug.c new file +64 -0
64 lines not on this page · raw message
hw/acpi/piix4.c +6 -71
131 lines not on this page · raw message
hw/acpi/Makefile.objs +1 -1
@@ -1 +1 @@ -common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o +common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o
Signature · 1 line
MST
[Qemu-devel] [PULL 22/29] acpi: ich9: add CPU hotplug handling to Q35 machine
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
.. use IO port 0cd8-0xcf7 range for CPU present bitmap
--- include/hw/acpi/cpu_hotplug_defs.h | 1 + include/hw/acpi/ich9.h | 4 ++++ hw/acpi/ich9.c | 14 ++++++++++++++ docs/specs/acpi_cpu_hotplug.txt | 4 +++- 4 files changed, 22 insertions(+), 1 deletion(-)
include/hw/acpi/cpu_hotplug_defs.h +1 -0
@@ -18,5 +18,6 @@*/ #define ACPI_CPU_HOTPLUG_STATUS 4#define ACPI_GPE_PROC_LEN 32 +#define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8#endif
include/hw/acpi/ich9.h +4 -0
@@ -22,6 +22,7 @@#define HW_ACPI_ICH9_H #include "hw/acpi/acpi.h" +#include "hw/acpi/cpu_hotplug.h" typedef struct ICH9LPCPMRegs { /*
@@ -42,6 +43,9 @@ typedef struct ICH9LPCPMRegs {uint32_t pm_io_base;Notifier powerdown_notifier; + +AcpiCpuHotplug gpe_cpu; +Notifier cpu_added_notifier; } ICH9LPCPMRegs; void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
hw/acpi/ich9.c +14 -0
@@ -185,6 +185,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)acpi_pm1_evt_power_down (&pm->acpi_regs); } +static void ich9_cpu_added_req (Notifier *n,void *opaque) +{ +ICH9LPCPMRegs *pm =container_of (n, ICH9LPCPMRegs, cpu_added_notifier); + +assert (pm !=NULL ); +AcpiCpuHotplug_add (&pm->acpi_regs.gpe, &pm->gpe_cpu,CPU (opaque)); +acpi_update_sci (&pm->acpi_regs, pm->irq); +} +void ich9_pm_init (PCIDevice *lpc_pci,ICH9LPCPMRegs *pm,qemu_irq sci_irq) {
@@ -210,6 +219,11 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,qemu_register_reset (pm_reset, pm); pm->powerdown_notifier.notify = pm_powerdown_req;qemu_register_powerdown_notifier (&pm->powerdown_notifier); + +AcpiCpuHotplug_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), + &pm->gpe_cpu,ICH9_CPU_HOTPLUG_IO_BASE ); + pm->cpu_added_notifier.notify = ich9_cpu_added_req; +qemu_register_cpu_added_notifier (&pm->cpu_added_notifier); } static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v,
docs/specs/acpi_cpu_hotplug.txt +3 -1
@@ -10,7 +10,9 @@ ACPI GPE block (IO ports 0xafe0-0xafe3, byte access): Generic ACPI GPE block. Bit 2 (GPE.2) used to notify CPU hot-add/remove event to ACPI BIOS, via SCI interrupt. -CPU present bitmap (IO port 0xaf00-0xaf1f, 1-byte access): +CPU present bitmap for: + ICH9-LPC (IO port 0x0cd8-0xcf7, 1-byte access) + PIIX-PM (IO port 0xaf00-0xaf1f, 1-byte access) --------------------------------------------------------------- One bit per CPU. Bit position reflects corresponding CPU APIC ID. Read-only.
Signature · 1 line
MST
Quoted 11 lines · Michael S. Tsirkin
The following changes since commit
1cf892ca2689c84960b4ce4d2723b6bee453711c:SPARC: Fix LEON3 power down instruction (2014-01-15 15:37:33 +1000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_anthonyfor you to fetch changes up to
ed25eb3675186b7bbb0c9876fe0e7cf8fa868642:acpi-test: update expected AML since recent changes (2014-01-20 16:06:14 +0200)
Hi Anthony,
I guess this got lost because I forgot to Cc you? I'll send a new one with more stuff that got buffered up since.
Quoted 126 lines
----------------------------------------------------------------
acpi,pci,pc,virtio fixes and enhancementsThis includes new unit-tests for acpi by Marcel, hotplug for pci bridges by myself (piix only so far) and cpu hotplug for q35.
And a bunch of fixes all over the place as usual.Still keeping memory alignment fix for q35 out of tree in the hope that we can fix it without limiting 32 bit guests to 2G RAM.
Signed-off-by Michael S. Tsirkin <[email protected]>----------------------------------------------------------------
Alexey Kardashevskiy (1):
tests: fix acpi to work on bigendian hostGabriel L. Somlo (2):
Add DSDT node for AppleSMC
ACPI: Fix AppleSMC_STAsizeIgor Mammedov (9):
pc: make: fix dependencies: rebuild when included file is changed
acpi: factor out common cpu hotplug code for PIIX4/Q35
acpi: ich9: add CPU hotplug handling to Q35 machine
pc: set PRST base in DSDT depending on chipset
pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 IO range from PCI bus resources
pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources
pc: ACPI: expose PRST IO range via_CRS
pc: ACPI: unify source of CPU hotplug IO base/len
pc: ACPI: update acpi-dsdt.hex.generated q35-acpi-dsdt.hex.generatedLaszlo Ersek (1):
Python-lang gdb script to extractx86_64guest vmcore from qemu coredumpMarcel Apfelbaum (10):
acpi unit-test: add test files
configure: added acpi unit-test files
acpi unit-test: compare DSDT and SSDT tables against expected values
configure: addCONFIG_IASLtoconfig-host.h
acpi unit-test: extract iasl executable from configuration acpi unit-test: added script to rebuild the expected aml files acpi unit-test: hook to rebuild expected aml files
acpi unit-test: renamedssdt_tablesto tables
acpi unit-test: resolved iasl crash
acpi unit-test: do not fail on asl mismatchMichael S. Tsirkin (5):
pci: addpci_for_each_bus_depth_first
pcihp: generalization of piix4 acpi
piix4: add acpi pci hotplug support
acpi-build: enable hotplug for PCI bridges
acpi-test: update expected AML since recent changesStefan Weil (1):
virtio: Fix return value for dummy functionvhost_net_virtqueue_pendingconfigure | 4 + include/hw/acpi/cpu_hotplug.h | 27 ++ include/hw/acpi/cpu_hotplug_defs.h | 24 ++ include/hw/acpi/ich9.h | 4 + include/hw/acpi/pcihp.h | 72 ++++++ include/hw/i386/pc.h | 5 + include/hw/isa/isa.h | 7 + include/hw/pci/pci.h | 14 ++ hw/acpi/cpu_hotplug.c | 64 +++++ hw/acpi/ich9.c | 14 ++ hw/acpi/pcihp.c | 316 ++++++++++++++++++++++++ hw/acpi/piix4.c | 155 ++++++------ hw/i386/acpi-build.c | 354 +++++++++++++++++++++------ hw/misc/applesmc.c | 1 - hw/net/vhost_net.c | 2 +- hw/pci/pci.c | 28 +++ tests/acpi-test.c | 305 ++++++++++++++++++++--- docs/specs/acpi_cpu_hotplug.txt | 4 +- hw/acpi/Makefile.objs | 3 +- hw/i386/Makefile.objs | 2 +- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 14 +- hw/i386/acpi-dsdt-isa.dsl | 11 + hw/i386/acpi-dsdt-pci-crs.dsl | 15 +- hw/i386/acpi-dsdt.dsl | 76 ++++-- hw/i386/acpi-dsdt.hex.generated | 217 +++++++++++----- hw/i386/q35-acpi-dsdt.dsl | 19 ++ hw/i386/q35-acpi-dsdt.hex.generated | 74 +++++- hw/i386/ssdt-pcihp.dsl | 11 +- hw/i386/ssdt-pcihp.hex.generated | 20 +- hw/i386/ssdt-proc.hex.generated | 6 +- scripts/create_config | 4 + scripts/dump-guest-memory.py | 339 +++++++++++++++++++++++++ tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes tests/acpi-test-data/pc/DSDT | Bin 0 -> 4582 bytes tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes tests/acpi-test-data/pc/SSDT | Bin 0 -> 2200 bytes tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes tests/acpi-test-data/q35/DSDT | Bin 0 -> 7438 bytes tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes tests/acpi-test-data/q35/SSDT | Bin 0 -> 475 bytes tests/acpi-test-data/rebuild-expected-aml.sh | 36 +++ 46 files changed, 1927 insertions(+), 320 deletions(-) create mode 100644 include/hw/acpi/cpu_hotplug.h create mode 100644 include/hw/acpi/cpu_hotplug_defs.h create mode 100644 include/hw/acpi/pcihp.h create mode 100644 hw/acpi/cpu_hotplug.c create mode 100644 hw/acpi/pcihp.c create mode 100644 scripts/dump-guest-memory.py create mode 100644 tests/acpi-test-data/pc/APIC create mode 100644 tests/acpi-test-data/pc/DSDT create mode 100644 tests/acpi-test-data/pc/FACP create mode 100644 tests/acpi-test-data/pc/FACS create mode 100644 tests/acpi-test-data/pc/HPET create mode 100644 tests/acpi-test-data/pc/SSDT create mode 100644 tests/acpi-test-data/q35/APIC create mode 100644 tests/acpi-test-data/q35/DSDT create mode 100644 tests/acpi-test-data/q35/FACP create mode 100644 tests/acpi-test-data/q35/FACS create mode 100644 tests/acpi-test-data/q35/HPET create mode 100644 tests/acpi-test-data/q35/MCFG create mode 100644 tests/acpi-test-data/q35/SSDT create mode 100755 tests/acpi-test-data/rebuild-expected-aml.sh