summaryrefslogtreecommitdiff
path: root/hw/misc
AgeCommit message (Collapse)AuthorFilesLines
2014-03-12misc/max111x: QOM casting sweepPeter Crosthwaite1-5/+9
Define and use QOM cast macro. Removes some usages of legacy casting systems. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> [AF: Rename parent field] Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-03-12misc/max111x: Create abstract max111x typePeter Crosthwaite1-8/+25
Create an abstract class that encompasses both max111x variants. This is needed for QOM cast macro creation (and is the right thing to do anyway). Macroify type-names in the process. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-03-12ssi: Convert legacy SSI_SLAVE -> DEVICE castsPeter Crosthwaite1-4/+5
Convert legacy ->qdev style casts from TYPE_SSI_SLAVE to TYPE_DEVICE. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> [AF: Introduce local DeviceState variable for transition to QOM realize] Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-02-27Merge remote-tracking branch ↵Peter Maydell1-3/+76
'remotes/awilliam/tags/vfio-pci-for-qemu-20140226.0' into staging Updates include: - Coverify fixes for vfio & pci-assign (Markus) - VFIO blacklisting support for known brokwn PCI option ROMs (Bandan) # gpg: Signature made Wed 26 Feb 2014 18:15:28 GMT using RSA key ID 3BB08B22 # gpg: Can't check signature: public key not found * remotes/awilliam/tags/vfio-pci-for-qemu-20140226.0: vfio: blacklist loading of unstable roms qdev-monitor: set DeviceState opts before calling realize pci-assign: Fix potential read beyond buffer on -EBUSY vfio: Fix overrun after readlink() fills buffer completely Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-02-26vfio: blacklist loading of unstable romsBandan Das1-0/+73
Certain cards such as the Broadcom BCM57810 have rom quirks that exhibit unstable system behavior duing device assignment. In the particular case of 57810, rom execution hangs and if a FLR follows, the device becomes inoperable until a power cycle. This change blacklists loading of rom for such cards unless the user specifies a romfile or rombar=1 on the cmd line Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-02-26vfio: Fix overrun after readlink() fills buffer completelyMarkus Armbruster1-3/+3
readlink() returns the number of bytes written to the buffer, and it doesn't write a terminating null byte. vfio_init() writes it itself. Overruns the buffer when readlink() filled it completely. Fix by treating readlink() filling the buffer completely as error, like we do in pci-assign.c's assign_failed_examine(). Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-02-26hw/misc/arm_sysctl: Fix bad boundary check on mb clock accessesPeter Maydell1-2/+2
Fix incorrect use of sizeof() rather than ARRAY_SIZE() to guard accesses into the mb_clock[] array, which was allowing a malicious guest to overwrite the end of the array. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Message-id: 1392647854-8067-2-git-send-email-peter.maydell@linaro.org Cc: qemu-stable@nongnu.org
2014-02-14qdev: Remove hex8/32/64 property typesPaolo Bonzini3-4/+4
Replace them with uint8/32/64. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-02-11Merge remote-tracking branch ↵Peter Maydell1-0/+5
'remotes/pmaydell/tags/pull-target-arm-20140208' into staging target-arm queue: * more A64 Neon instructions * AArch32 VCVTB and VCVTT ARMv8 instructions * fixes to inaccuracies in GIC emulation * libvixl disassembler for A64 * Allwinner SoC ethernet controller * zynq software system reset support # gpg: Signature made Sat 08 Feb 2014 15:53:05 GMT using RSA key ID 14360CDE # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" * remotes/pmaydell/tags/pull-target-arm-20140208: (29 commits) arm/zynq: Add software system reset via SCLR hw/arm/allwinner-a10: initialize EMAC hw/net: add support for Allwinner EMAC Fast Ethernet controller util/fifo8: clear fifo head upon reset util/fifo8: implement push/pop of multiple bytes disas: Implement disassembly output for A64 disas/libvixl: Fix upstream libvixl compilation issues disas: Add subset of libvixl sources for A64 disassembler rules.mak: Link with C++ if we have a C++ compiler rules.mak: Support .cc as a C++ source file suffix arm_gic: Add GICC_APRn state to the GICState vmstate: Add uint32 2D-array support arm_gic: Support setting/getting binary point reg arm_gic: Keep track of SGI sources arm_gic: Fix GIC pending behavior target-arm: Add support for AArch32 64bit VCVTB and VCVTT target-arm: A64: Add FNEG and FABS to the SIMD 2-reg-misc group target-arm: A64: Add 2-reg-misc REV* instructions target-arm: A64: Add narrowing 2-reg-misc instructions target-arm: A64: Implement 2-reg-misc CNT, NOT and RBIT ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-02-08arm/zynq: Add software system reset via SCLRSebastian Huber1-0/+5
Support software-driven system reset via the register in the SCLR. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-02-04lm32_sys: dump cpu state if test case failsMichael Walle1-0/+3
This will ease debugging the test cases. Signed-off-by: Michael Walle <michael@walle.cc>
2014-02-04lm32_sys: print test result on stderrMichael Walle1-1/+1
Do not use qemu_log(). Signed-off-by: Michael Walle <michael@walle.cc>
2014-02-04lm32_sys: increase test case name length limitMichael Walle1-2/+3
The new MMU tests use longer names. Signed-off-by: Michael Walle <michael@walle.cc>
2014-02-01Merge remote-tracking branch ↵Peter Maydell1-11/+67
'remotes/awilliam/tags/vfio-pci-for-qemu-20140128.0' into staging vfio-pci updates include: - Destroy MemoryRegions on device teardown - Print warnings around PCI option ROM failures - Skip bogus mappings from 64bit BAR sizing - Act on DMA mapping failures - Fix alignment to avoid MSI-X table mapping - Fix debug macro typo # gpg: Signature made Tue 28 Jan 2014 15:27:47 GMT using RSA key ID 3BB08B22 # gpg: Can't check signature: public key not found * remotes/awilliam/tags/vfio-pci-for-qemu-20140128.0: vfio: correct debug macro typo vfio: fix mapping of MSIX bar kvm: initialize qemu_host_page_size vfio-pci: Fail initfn on DMA mapping errors vfio: Filter out bogus mappings vfio: Do not reattempt a failed rom read vfio: warn if host device rom can't be read vfio: Destroy memory regions Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-01-28vfio: correct debug macro typoBandan Das1-1/+1
Change to DEBUG_VFIO in vfio_msi_interrupt() for debug messages to get printed Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-01-26Add DSDT node for AppleSMCGabriel L. Somlo1-1/+0
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. Signed-off-by: Gabriel Somlo <somlo@cmu.edu> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-01-17vfio: fix mapping of MSIX barAlexey Kardashevskiy1-3/+3
VFIO virtualizes MSIX table for the guest but not mapping the part of a BAR which contains an MSIX table. Since vfio_mmap_bar() mmaps chunks before and after the MSIX table, they have to be aligned to the host page size which may be TARGET_PAGE_MASK (4K) or 64K in case of PPC64. This fixes boundaries calculations to use the real host page size. Without the patch, the chunk before MSIX table may overlap with the MSIX table and mmap will fail in the host kernel. The result will be serious slowdown as the whole BAR will be emulated by QEMU. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-01-16vfio-pci: Fail initfn on DMA mapping errorsAlex Williamson1-6/+38
The vfio-pci initfn will currently succeed even if DMA mappings fail. A typical reason for failure is if the user does not have sufficient privilege to lock all the memory for the guest. In this case, the device gets attached, but can only access a portion of guest memory and is extremely unlikely to work. DMA mappings are done via a MemoryListener, which provides no direct error return path. We therefore stuff the errno into our container structure and check for error after registration completes. We can also test for mapping errors during runtime, but our only option for resolution at that point is to kill the guest with a hw_error. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-01-16vfio: Filter out bogus mappingsAlex Williamson1-1/+8
Since 57271d63 we now see spurious mappings with the upper bits set if 64bit PCI BARs are sized while enabled. The guest writes a mask of 0xffffffff to the lower BAR to size it, then restores it, then writes the same mask to the upper BAR resulting in a spurious BAR mapping into the last 4G of the 64bit address space. Most architectures do not support or make use of the full 64bits address space for PCI BARs, so we filter out mappings with the high bit set. Long term, we probably need to think about vfio telling us the address width limitations of the IOMMU. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
2014-01-15vfio: Do not reattempt a failed rom readBandan Das1-0/+6
During lazy rom loading, if rom read fails, and the guest attempts a read again, vfio will again attempt it. Add a boolean to prevent this. There could be a case where a failed rom read might succeed the next time because of a device reset or such, but it's best to exclude unpredictable behavior Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-01-15vfio: warn if host device rom can't be readBandan Das1-0/+7
If the device rom can't be read, report an error to the user. This alerts the user that the device has a bad state that is causing rom read failure or option rom loading has been disabled from the device boot menu (among other reasons). Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-01-15vfio: Destroy memory regionsAlex Williamson1-0/+4
Somehow this has been lurking for a while; we remove our subregions from the base BAR and VGA region mappings, but we don't destroy them, creating a leak and more serious problems when we try to migrate after removing these devices. Add the trivial bit of final cleanup to remove these entirely. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2014-01-09Merge remote-tracking branch 'afaerber/tags/qom-devices-for-anthony' into ↵Anthony Liguori2-2/+2
staging QOM infrastructure fixes and device conversions * QOM interface fixes and unit test * Device no_user sanitization and documentation * Device error reporting improvement * Conversion of APIC, ICC, IOAPIC to QOM realization model # gpg: Signature made Tue 24 Dec 2013 09:04:05 AM PST using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 174F 0347 1BCC 221A 6175 6F96 FA2E D12D 3E7E 013F * afaerber/tags/qom-devices-for-anthony: (24 commits) qdev-monitor: Improve error message for -device nonexistant ioapic: QOM'ify ioapic ioapic: Cleanup for QOM'ification icc_bus: QOM'ify ICC apic: QOM'ify APIC apic: Cleanup for QOM'ification qdev: Drop misleading qbus_free() function qom: Detect bad reentrance during object_class_foreach() tests: Test QOM interface casting qom: Do not register interface "types" in the type table and fix names qom: Split out object and class caches qdev: Document that pointer properties kill device_add hw: cannot_instantiate_with_device_add_yet due to pointer props qdev-monitor: Avoid device_add crashing on non-device driver name qdev: Do not let the user try to device_add when it cannot work isa: Clean up use of cannot_instantiate_with_device_add_yet vt82c686: Clean up use of cannot_instantiate_with_device_add_yet piix3 piix4: Clean up use of cannot_instantiate_with_device_add_yet ich9: Document why cannot_instantiate_with_device_add_yet pci-host: Consistently set cannot_instantiate_with_device_add_yet ...
2013-12-23exynos4210: Use macro ARRAY_SIZE where possibleStefan Weil1-2/+1
This improves readability and simplifies the code. Cc: Dmitry Solodkiy <d.solodkiy@samsung.com> Cc: Evgeny Voevodin <e.voevodin@samsung.com> Cc: Igor Mitsyanko <i.mitsyanko@gmail.com> Cc: Maksim Kozlov <m.kozlov@samsung.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-12-23isa: Clean up use of cannot_instantiate_with_device_add_yetMarkus Armbruster1-1/+2
Drop it when there's no obvious reason why device_add could not work. Else keep and document why. * isa-fdc: drop * i8042: drop, even though its I/O base is hardcoded (because you could conceivably still add one to a board that has none), and even though PC board code wires up the A20 line (because that wiring is optional) * port92: keep because it needs additional wiring by port92_init() * mc146818rtc: keep because it needs to be wired up by rtc_init() * m48t59_isa: keep because needs to be wired up by m48t59_init_isa() * isa-pit, kvm-pit: keep (in their abstract base pic-common) because the PIT needs additional wiring by board code, depending on HPET presence * pcspk: keep because of pointer property pit, and because realize sets global pcspk_state * vmmouse: keep because of pointer property ps2_mouse * vmport: keep because realize sets global port_state * isa-i8259, kvm-i8259: keep (in their abstract base pic-common), because the PICs' IRQ input lines are set up by board code, and the wiring of the slave to the master is hard-coded in device model code Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-12-23sysbus: Set cannot_instantiate_with_device_add_yetMarkus Armbruster1-1/+0
device_add plugs devices into suitable bus. For "real" buses, that actually connects the device. For sysbus, the connections need to be made separately, and device_add can't do that. The device would be left unconnected, and could not possibly work. Quite a few, but not all sysbus devices already set cannot_instantiate_with_device_add_yet in their class init function. Set it in their abstract base's class init function sysbus_device_class_init(), and remove the now redundant assignments from device class init functions. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-12-23qdev: Replace no_user by cannot_instantiate_with_device_add_yetMarkus Armbruster2-2/+2
In an ideal world, machines can be built by wiring devices together with configuration, not code. Unfortunately, that's not the world we live in right now. We still have quite a few devices that need to be wired up by code. If you try to device_add such a device, it'll fail in sometimes mysterious ways. If you're lucky, you get an unmysterious immediate crash. To protect users from such badness, DeviceClass member no_user used to make device models unavailable with -device / device_add, but that regressed in commit 18b6dad. The device model is still omitted from help, but is available anyway. Attempts to fix the regression have been rejected with the argument that the purpose of no_user isn't clear, and it's prone to misuse. This commit clarifies no_user's purpose. Anthony suggested to rename it cannot_instantiate_with_device_add_yet_due_to_internal_bugs, which I shorten somewhat to keep checkpatch happy. While there, make it bool. Every use of cannot_instantiate_with_device_add_yet gets a FIXME comment asking for rationale. The next few commits will clean them all up, either by providing a rationale, or by getting rid of the use. With that done, the regression fix is hopefully acceptable. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-12-06vfio-pci: Release all MSI-X vectors when disabledAlex Williamson1-0/+12
We were relying on msix_unset_vector_notifiers() to release all the vectors when we disable MSI-X, but this only happens when MSI-X is still enabled on the device. Perform further cleanup by releasing any remaining vectors listed as in-use after this call. This caused a leak of IRQ routes on hotplug depending on how the guest OS prepared the device for removal. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Cc: qemu-stable@nongnu.org
2013-12-06vfio-pci: Add debug config options to disable MSI/X KVM supportAlex Williamson1-4/+20
It's sometimes useful to be able to verify interrupts are passing through correctly. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2013-12-06vfio-pci: Fix Nvidia MSI ACK through 0x88000 quirkAlex Williamson1-1/+29
When MSI is enabled on Nvidia GeForce cards the driver seems to acknowledge the interrupt by writing a 0xff byte to the MSI capability ID register using the PCI config space mirror at offset 0x88000 from BAR0. Without this, the device will only fire a single interrupt. VFIO handles the PCI capability ID/next registers as virtual w/o write support, so any write through config space is currently dropped. Add a check for this and allow the write through the BAR window. The registers are read-only anyway. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2013-12-06vfio-pci: Make use of new KVM-VFIO deviceAlex Williamson1-0/+67
Add and remove groups from the KVM virtual VFIO device as we make use of them. This allows KVM to optimize for performance and correctness based on properties of the group. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2013-11-21vfio-pci: Fix multifunction=onAlex Williamson1-0/+7
When an assigned device is initialized it copies the device config space into the emulated config space. Unfortunately multifunction is setup prior to the device initfn and gets clobbered. We need to restore it just like pci-assign does. Cc: qemu-stable@nongnu.org Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-11-21pc: get rid of builtin pvpanic for "-M pc-1.5"Paolo Bonzini1-5/+0
This causes two slight backwards-incompatibilities between "-M pc-1.5" and 1.5's "-M pc": (1) a fw_cfg file is removed with this patch. This is only a problem if migration stops the virtual machine exactly during fw_cfg enumeration. (2) after migration, a VM created without an explicit "-device pvpanic" will stop reporting panics to management. The first problem only occurs if migration is done at a very, very early point (and I'm not sure it can happen in practice for reasonable-size VMs, since it will likely take more time to send the RAM to destination, than it will take for BIOS to scan fw_cfg). The second problem only occurs if the guest panics _and_ has a guest driver _and_ management knows to look at the crash event, so it is mostly theoretical at this point in time. Thus keep the code simple, and pretend it was never broken. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-11-05pcmcia: QOM'ify PCMCIACardState and MicroDriveStateAndreas Färber2-208/+0
Turn PCMCIACardState into a device. Move callbacks to new PCMCIACardClass. Derive TYPE_MICRODRIVE from TYPE_PCMCIA_CARD. Replace ide_init2_with_non_qdev_drives(). Signed-off-by: Othmar Pasteka <pasteka@kabsi.at> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-11-05pxa: Fix typo "dettach"Andreas Färber1-1/+1
Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-11-05arm11mpcore: Split off SCU deviceAndreas Färber2-0/+101
Inspired by a9scu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-11-05a9scu: Build only onceAndreas Färber1-1/+1
It does not have a target or ARMCPU dependency. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-11-05a9mpcore: Embed A9SCUStateAndreas Färber1-17/+1
Prepares for QOM realize. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2013-11-05a9scu: QOM cleanupsAndreas Färber1-6/+9
Rename A9SCUState::busdev field to parent_obj and turn realizefn into an instance_init function to allow early MMIO mapping. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2013-10-31Merge remote-tracking branch 'mst/tags/for_anthony' into stagingAnthony Liguori3-7/+19
pci, pc, acpi fixes, enhancements This includes some pretty big changes: - pci master abort support by Marcel - pci IRQ API rework by Marcel - acpi generation support by myself Everything has gone through several revisions, latest versions have been on list for a while without any more comments, tested by several people. Please pull for 1.7. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Tue 15 Oct 2013 07:33:48 AM CEST using RSA key ID D28D5469 # gpg: Can't check signature: public key not found * mst/tags/for_anthony: (39 commits) ssdt-proc: update generated file ssdt: fix PBLK length i386: ACPI table generation code from seabios pc: use new api to add builtin tables acpi: add interface to access user-installed tables hpet: add API to find it pvpanic: add API to access io port ich9: APIs for pc guest info piix: APIs for pc guest info acpi/piix: add macros for acpi property names i386: define pc guest info loader: allow adding ROMs in done callbacks i386: add bios linker/loader loader: use file path size from fw_cfg.h acpi: ssdt pcihp: updat generated file acpi: pre-compiled ASL files acpi: add rules to compile ASL source i386: add ACPI table files from seabios q35: expose mmcfg size as a property q35: use macro for MCFG property name ... Message-id: 1381818560-18367-1-git-send-email-mst@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-10-31integrator: fix Linux boot failure by emulating dbg regionAlex Bennée2-0/+100
Commit 9b8c69243 (since reverted) broke the ability to boot the kernel as the value returned by unassigned_mem_read returned non-zero and left the kernel looping forever waiting for it to change (see integrator_led_set in the kernel code). Relying on a varying implementation detail is incorrect anyway so this introduces a basic stub of a memory region for the debug/LED section on the integrator board. Signed-off-by: Alex Bennée <alex@bennee.com> Message-id: 1382451366-9539-1-git-send-email-alex.bennee@linaro.org [PMM: removed three unused fields from struct IntegratorDebugState] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2013-10-14pvpanic: add API to access io portMichael S. Tsirkin1-1/+12
Add API to find pvpanic device and get its io port. Will be used to fill in guest info structure. Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-10-14hw: set interrupts using pci irq wrappersMarcel Apfelbaum1-1/+1
pci_set_irq and the other pci irq wrappers use PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. An irq is allocated using pci_allocate_irq wrapper only if is needed by non pci devices. Removed irq related fields from state if not used anymore. Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-10-14hw/vfio: set interrupts using pci irq wrappersMarcel Apfelbaum1-5/+6
pci_set_irq and the other pci irq wrappers use PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. save INTX pin into the config register before calling pci_set_irq Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-10-04vfio-pci: Fix endian issues in vfio_pci_size_rom()Alex Williamson1-2/+2
VFIO is always little endian so do byte swapping of our mask on the way in and byte swapping of the size on the way out. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2013-10-04vfio-pci: Add dummy PCI ROM write accessorAlex Williamson1-0/+6
Just to be sure we don't jump off any NULL pointer cliffs. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
2013-10-03vfio: Fix debug output for int128 valuesAlexey Kardashevskiy1-2/+4
Memory regions can easily be 2^64 byte long and therefore overflow for just a bit but that is enough for int128_get64() to assert. This takes care of debug printing of huge section sizes. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2013-10-02vfio-pci: Implement PCI hot resetAlex Williamson1-38/+300
Now that VFIO has a PCI hot reset interface, take advantage of it. There are two modes that we need to consider. The first is when only one device within the set of devices affected is actually assigned to the guest. In this case the other devices are are just held by VFIO for isolation and we can pretend they're not there, doing an entire bus reset whenever the device reset callback is triggered. Supporting this case separately allows us to do the best reset we can do of the device even if the device is hotplugged. The second mode is when multiple affected devices are all exposed to the guest. In this case we can only do a hot reset when the entire system is being reset. However, this also allows us to track which individual devices are affected by a reset and only do them once. We split our reset function into pre- and post-reset helper functions prioritize the types of device resets available to us, and create separate _one vs _multi reset interfaces to handle the distinct cases above. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2013-10-02vfio-pci: Cleanup error_reportsAlex Williamson1-12/+12
Remove carriage returns and tweak formatting for error_reports. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2013-10-02vfio-pci: Lazy PCI option ROM loadingAlex Williamson1-62/+122
During vfio-pci initfn, the device is not always in a state where the option ROM can be read. In the case of graphics cards, there's often no per function reset, which means we have host driver state affecting whether the option ROM is usable. Ideally we want to move reading the option ROM past any co-assigned device resets to the point where the guest first tries to read the ROM itself. To accomplish this, we switch the memory region for the option rom to an I/O region rather than a memory mapped region. This has the side benefit that we don't waste KVM memory slots for a BAR where we don't care about performance. This also allows us to delay loading the ROM from the device until the first read by the guest. We then use the PCI config space size of the ROM BAR when setting up the BAR through QEMU PCI. Another benefit of this approach is that previously when a user set the ROM to a file using the romfile= option, we still probed VFIO for the parameters of the ROM, which can result in dmesg errors about an invalid ROM. We now only probe VFIO to get the ROM contents if the guest actually tries to read the ROM. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>