]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
9 years agohw/arm/virt-acpi-build: Generate MCFG table
Shannon Zhao [Fri, 29 May 2015 10:28:57 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generate MCFG table

Generate MCFG table for PCIe controller.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-14-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Generate RSDP table
Shannon Zhao [Fri, 29 May 2015 10:28:56 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generate RSDP table

RSDP points to RSDT which in turn points to other tables.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-13-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Generate RSDT table
Shannon Zhao [Fri, 29 May 2015 10:28:56 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generate RSDT table

RSDT points to other tables FADT, MADT, GTDT. This code is shared with x86.

Here we still use RSDT as UEFI puts ACPI tables below 4G address space,
and UEFI ignore the RSDT or XSDT.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-12-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Generate GTDT table
Shannon Zhao [Fri, 29 May 2015 10:28:56 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generate GTDT table

ACPI v5.1 defines GTDT for ARM devices as a place to describe timer
related information in the system. The Arch Timer interrupts must
be provided for GTDT.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-11-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Generate MADT table
Shannon Zhao [Fri, 29 May 2015 10:28:56 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generate MADT table

MADT describes GIC enabled ARM platforms. The GICC and GICD
subtables are used to define the GIC regions.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-10-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Generate FADT table and update ACPI headers
Shannon Zhao [Fri, 29 May 2015 10:28:55 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers

In the case of mach virt, it is used to set the Hardware Reduced bit
and enable PSCI SMP booting through HVC. So ignore FACS and FADT
points to DSDT.

Update the header definitions for FADT taking into account the new
additions of ACPI v5.1 in `include/hw/acpi/acpi-defs.h`

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Message-id: 1432522520-8068-9-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Generation of DSDT table for virt devices
Shannon Zhao [Fri, 29 May 2015 10:28:55 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Generation of DSDT table for virt devices

DSDT consists of the usual common table header plus a definition
block in AML encoding which describes all devices in the platform.

After initializing DSDT with header information the namespace is
created which is followed by the device encodings. The devices are
described using the Resource Template for the 32-Bit Fixed Memory
Range and the Extended Interrupt Descriptors.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-8-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/acpi/aml-build: Add aml_interrupt() term
Shannon Zhao [Fri, 29 May 2015 10:28:55 +0000 (11:28 +0100)]
hw/acpi/aml-build: Add aml_interrupt() term

Add aml_interrupt() for describing device interrupt in resource template.
These can be used to generating DSDT table for ACPI on ARM.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-id: 1432522520-8068-7-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/acpi/aml-build: Add aml_memory32_fixed() term
Shannon Zhao [Fri, 29 May 2015 10:28:55 +0000 (11:28 +0100)]
hw/acpi/aml-build: Add aml_memory32_fixed() term

Add aml_memory32_fixed() for describing device mmio region in resource
template. These can be used to generating DSDT table for ACPI on ARM.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-id: 1432522520-8068-6-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt-acpi-build: Basic framework for building ACPI tables on ARM
Shannon Zhao [Fri, 29 May 2015 10:28:54 +0000 (11:28 +0100)]
hw/arm/virt-acpi-build: Basic framework for building ACPI tables on ARM

Introduce a preliminary framework in virt-acpi-build.c with the main
ACPI build functions. It exposes the generated ACPI contents to
guest over fw_cfg.

The required ACPI v5.1 tables for ARM are:
- RSDP: Initial table that points to XSDT
- RSDT: Points to FADT GTDT MADT tables
- FADT: Generic information about the machine
- GTDT: Generic timer description table
- MADT: Multiple APIC description table
- DSDT: Holds all information about system devices/peripherals, pointed by FADT

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-id: 1432522520-8068-5-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt: Record PCIe ranges in MemMapEntry array
Shannon Zhao [Fri, 29 May 2015 10:28:54 +0000 (11:28 +0100)]
hw/arm/virt: Record PCIe ranges in MemMapEntry array

To generate ACPI table for PCIe controller, we need the base and size of
the PCIe ranges. Record these ranges in MemMapEntry array, then we could
share and use them for generating ACPI table.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Message-id: 1432522520-8068-4-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/arm/virt: Move common definitions to virt.h
Shannon Zhao [Fri, 29 May 2015 10:28:54 +0000 (11:28 +0100)]
hw/arm/virt: Move common definitions to virt.h

Move some common definitions to virt.h. These will be used by
generating ACPI tables.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1432522520-8068-3-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agohw/acpi/aml-build: Make enum values to be upper case to match coding style
Shannon Zhao [Fri, 29 May 2015 10:28:54 +0000 (11:28 +0100)]
hw/acpi/aml-build: Make enum values to be upper case to match coding style

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-id: 1432522520-8068-2-git-send-email-zhaoshenglong@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agotarget-arm: Add WFx instruction trap support
Greg Bellows [Fri, 29 May 2015 10:28:53 +0000 (11:28 +0100)]
target-arm: Add WFx instruction trap support

Add support for trapping WFI and WFE instructions to the proper EL when
SCTLR/SCR/HCR settings apply.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
[PMM: removed unnecessary tweaking of syn_wfx() prototype;
 use raise_exception();
 don't trap on WFE (and add comment explaining why not);
 remove unnecessary ARM_FEATURE checks;
 trap to EL3, not EL1, if in S-EL0 and SCTLR check fires]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Don't halt on WFI unless we don't have any work
Peter Maydell [Fri, 29 May 2015 10:28:53 +0000 (11:28 +0100)]
target-arm: Don't halt on WFI unless we don't have any work

Just NOP the WFI instruction if we have work to do.
This doesn't make much difference currently (though it does avoid
jumping out to the top level loop and immediately restarting),
but the distinction between "halt" and "don't halt" will become
more important when the decision to halt requires us to trap
to a higher exception level instead.

Suggested-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Move TB flags down to fill gap
Peter Maydell [Fri, 29 May 2015 10:28:53 +0000 (11:28 +0100)]
target-arm: Move TB flags down to fill gap

Deleting the now-unused ARM_TBFLAG_CPACR_FPEN left a gap in the
bit usage; move the following ARM_TBFLAG_XSCALE_CPAR and
ARM_TBFLAG_NS_SHIFT down 3 bits to fill the gap.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Extend FP checks to use an EL
Greg Bellows [Fri, 29 May 2015 10:28:53 +0000 (11:28 +0100)]
target-arm: Extend FP checks to use an EL

Extend the ARM disassemble context to take a target exception EL instead of a
boolean enable. This change reverses the polarity of the check making a value
of 0 indicate floating point enabled (no exception).

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
[PMM: Use a common TB flag field for AArch32 and AArch64;
 CPTR_EL2 exists in v7; CPTR_EL2 should trap for EL2 accesses;
 CPTR_EL2 should not trap for secure accesses; CPTR_EL3
 should trap for EL3 accesses; CPACR traps for secure
 accesses should trap to EL3 if EL3 is AArch32]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Make singlestate TB flags common between AArch32/64
Peter Maydell [Fri, 29 May 2015 10:28:52 +0000 (11:28 +0100)]
target-arm: Make singlestate TB flags common between AArch32/64

Currently we keep the TB flags PSTATE_SS and SS_ACTIVE in different
bit positions for AArch64 and AArch32. Replace these separate
definitions with a single common flag in the upper part of the
flags word.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Add AArch64 CPTR registers
Greg Bellows [Fri, 29 May 2015 10:28:52 +0000 (11:28 +0100)]
target-arm: Add AArch64 CPTR registers

Adds CPTR_EL2/3 system registers definitions and access function.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
[PMM: merge CPTR_EL2 and HCPTR definitions into a single
 def using STATE_BOTH;
 don't use readfn/writefn to implement RAZ/WI registers;
 don't use accessfn for the no-EL2 CPTR_EL2;
 fix cpacr_access logic to catch EL2 accesses to CPACR being
 trapped to EL3;
 use new CP_ACCESS_TRAP_EL[23] rather than setting
 exception.target_el directly]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Allow cp access functions to indicate traps to EL2 or EL3
Peter Maydell [Fri, 29 May 2015 10:28:52 +0000 (11:28 +0100)]
target-arm: Allow cp access functions to indicate traps to EL2 or EL3

Some coprocessor access functions will need to indicate that the
instruction should trap to EL2 or EL3 rather than the default
target exception level; add corresponding CPAccessResult enum
entries and handling code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Update interrupt handling to use target EL
Greg Bellows [Fri, 29 May 2015 10:28:51 +0000 (11:28 +0100)]
target-arm: Update interrupt handling to use target EL

Updated the interrupt handling to utilize and report through the target EL
exception field.  This includes consolidating and cleaning up code where
needed. Target EL is now calculated once in arm_cpu_exec_interrupt() and
do_interrupt was updated to use the target_el exception field.  The
necessary code from arm_excp_target_el() was merged in where needed and the
function removed.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1429722561-12651-4-git-send-email-greg.bellows@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agotarget-arm: Make raise_exception() take syndrome and target EL
Peter Maydell [Fri, 29 May 2015 10:28:51 +0000 (11:28 +0100)]
target-arm: Make raise_exception() take syndrome and target EL

Rather than making every caller of raise_exception set the
syndrome and target EL by hand, make these arguments to
raise_exception() and have that do the job.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Set exception target EL in tlb_fill
Peter Maydell [Fri, 29 May 2015 10:28:51 +0000 (11:28 +0100)]
target-arm: Set exception target EL in tlb_fill

Set the exception target EL for MMU faults in tlb_fill.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Move setting of exception info into tlb_fill
Peter Maydell [Fri, 29 May 2015 10:28:51 +0000 (11:28 +0100)]
target-arm: Move setting of exception info into tlb_fill

Move the code which sets exception information out of
arm_cpu_handle_mmu_fault and into tlb_fill. tlb_fill
is the only caller which wants to raise_exception()
so it makes more sense for it to handle the whole of
the exception setup.

As part of this cleanup, move the user-mode-only
implementation function for the handle_mmu_fault CPU
method into cpu.c so we don't need to make it globally
visible, and rename the softmmu-only utility function
arm_cpu_handle_mmu_fault to arm_tlb_fill so it's clear
that it's not the same thing.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Set correct syndrome for faults on MSR DAIF*, imm
Peter Maydell [Fri, 29 May 2015 10:28:50 +0000 (11:28 +0100)]
target-arm: Set correct syndrome for faults on MSR DAIF*, imm

If the SCTLR.UMA trap bit is set then attempts by EL0 to update
the PSTATE DAIF bits via "MSR DAIFSet, imm" and "MSR DAIFClr, imm"
instructions will raise an exception. We were failing to set
the syndrome information for this exception, which meant that
it would be reported as a repeat of whatever the previous
exception was. Set the correct syndrome information.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9 years agotarget-arm: Extend helpers to route exceptions
Greg Bellows [Fri, 29 May 2015 10:28:50 +0000 (11:28 +0100)]
target-arm: Extend helpers to route exceptions

Updated the various helper routines to set the target EL as needed using a
dedicated function.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1429722561-12651-3-git-send-email-greg.bellows@linaro.org
[PMM: Also set target_el in fault cases in access_check_cp_reg()]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agotarget-arm: Add exception target el infrastructure
Greg Bellows [Fri, 29 May 2015 10:28:50 +0000 (11:28 +0100)]
target-arm: Add exception target el infrastructure

Add a CPU state exception target EL field that will be used for communicating
the EL to which an exception should be routed.

Add a disassembly context field for tracking the EL3 architecture needed for
determining the target exception EL.

Add a target EL argument to the generic exception helper for callers to specify
the EL to which the exception should be routed.  Extended the helper to set
the newly added CPU state exception target el.

Added a function for setting the target exception EL and updated calls to helpers
to call it.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1429722561-12651-2-git-send-email-greg.bellows@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/spice/tags/pull-spice-20150529-1' into staging
Peter Maydell [Fri, 29 May 2015 09:17:48 +0000 (10:17 +0100)]
Merge remote-tracking branch 'remotes/spice/tags/pull-spice-20150529-1' into staging

spice: misc fixes.

# gpg: Signature made Fri May 29 09:16:29 2015 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/spice/tags/pull-spice-20150529-1:
  spice: fix spice_chr_add_watch() pre-condition
  spice: don't update mm_time when spice-server is stopped.
  spice-char: notify the server when chardev is writable
  virtio-console: notify chardev when writable

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agospice: fix spice_chr_add_watch() pre-condition
Marc-André Lureau [Thu, 28 May 2015 13:04:58 +0000 (15:04 +0200)]
spice: fix spice_chr_add_watch() pre-condition

Since e02bc6de30c44fd668dc0d6e1cd1804f2eed3ed3, add_watch() is called
with G_IO_HUP. Even if spice-qemu-char ignores this flag, the
precondition must be changed.

https://bugzilla.redhat.com/show_bug.cgi?id=1128992

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agospice: don't update mm_time when spice-server is stopped.
Gerd Hoffmann [Tue, 12 May 2015 09:54:34 +0000 (11:54 +0200)]
spice: don't update mm_time when spice-server is stopped.

Skip mm_time updates (in qxl device memory) in case the guest is stopped.
Guest isn't able to look anyway, and it causes problems with migration.

Also make sure the initial state for spice server is stopped.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agospice-char: notify the server when chardev is writable
Marc-André Lureau [Tue, 5 May 2015 14:58:56 +0000 (16:58 +0200)]
spice-char: notify the server when chardev is writable

The spice server is polling on write, unless
SPICE_CHAR_DEVICE_NOTIFY_WRITABLE flag is set. In this case, qemu must
call spice_server_char_device_wakeup() when the frontend is writable.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agovirtio-console: notify chardev when writable
Marc-André Lureau [Tue, 5 May 2015 14:58:55 +0000 (16:58 +0200)]
virtio-console: notify chardev when writable

When the virtio serial is writable, notify the chardev backend
with qemu_chr_accept_input().

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9 years agoRevert "gdbstub: Do not kill target in system emulation mode"
Fabien Chouteau [Sat, 7 Feb 2015 08:38:45 +0000 (09:38 +0100)]
Revert "gdbstub: Do not kill target in system emulation mode"

The requirements described in this patch are implemented by "Add GDB
qAttached support".

This reverts commit 00e94dbc7fd0110b0555d59592b004333adfb4b8.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoAdd GDB qAttached support
Jan Kiszka [Sat, 7 Feb 2015 08:38:44 +0000 (09:38 +0100)]
Add GDB qAttached support

With this patch QEMU handles qAttached request from gdb. When QEMU
replies 1, GDB sends a "detach" command at the end of a debugging
session otherwise GDB sends "kill".

The default value for qAttached is 1 on system emulation and 0 on user
emulation.

Based on original version by Fabien Chouteau.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agogdbstub: Introduce an is is_query_packet helper
Jan Kiszka [Sat, 7 Feb 2015 08:38:43 +0000 (09:38 +0100)]
gdbstub: Introduce an is is_query_packet helper

This helper supports parsing of query packets with optional extensions.
The separator can be specified so that we can use it already for both
qqemu.sstep[=] and qSupported[:feature].

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agogdbstub: Fix qOffsets packet detection
Jan Kiszka [Sat, 7 Feb 2015 08:38:42 +0000 (09:38 +0100)]
gdbstub: Fix qOffsets packet detection

qOffsets has no additional optional parameters. So match the complete
string to avoid stumbling over possible future commands with identical
prefix.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20150528' into staging
Peter Maydell [Thu, 28 May 2015 13:57:34 +0000 (14:57 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150528' into staging

A set of patches add support for vector registers on s390x.
Notable: Floating point registers and vector registers overlap,
so extra care is needed so that we end up with a consistent state
in all cases.

# gpg: Signature made Thu May 28 09:37:27 2015 BST using RSA key ID C6F02FAF
# gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"

* remotes/cohuck/tags/s390x-20150528:
  s390x: Enable vector processing capability
  s390x: Migrate vector registers
  s390x: Add vector registers to ELF dump
  linux/elf.h update
  s390x: Add vector registers to HMP output
  s390x: gdb updates for vector registers
  gdb-xml: Include XML for s390 vector registers
  s390x: Store Additional Status SIGP order
  s390x: Vector Register IOCTLs
  s390x: Common access to floating point registers

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
Peter Maydell [Thu, 28 May 2015 10:03:02 +0000 (11:03 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging

# gpg: Signature made Wed May 27 11:02:55 2015 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/net-pull-request:
  net/net: Record usage status of mac address
  tap: Improve -netdev/netdev_add/-net/... tap error reporting
  tap: Finish conversion of tap_open() to Error
  tap-solaris: Convert tap_open() to Error
  tap-bsd: Convert tap_open() to Error
  tap-linux: Convert tap_open() to Error
  tap: Permit incremental conversion of tap_open() to Error
  tap: Convert launch_script() to Error
  tap: Convert net_init_tap_one() to Error
  tap: Convert tap_set_sndbuf() to Error
  tap: Improve -netdev/netdev_add/-net/... bridge error reporting
  tap: net_tap_fd_init() can't fail, drop dead error handling
  net/dump: Improve -net/host_net_add dump error reporting
  net: Improve -net nic error reporting
  net: Permit incremental conversion of init functions to Error
  net: Improve error message for -net hubport a bit
  net: Change help text to list -netdev instead of -net by default

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agos390x: Enable vector processing capability
Eric Farman [Thu, 30 Oct 2014 13:23:06 +0000 (09:23 -0400)]
s390x: Enable vector processing capability

Everything is finally in place, inform the kernel that user space
supports vector registers.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: Migrate vector registers
Eric Farman [Thu, 7 May 2015 14:52:16 +0000 (10:52 -0400)]
s390x: Migrate vector registers

When migrating a guest, be sure to include the vector registers.
The vector registers are defined in a subsection, similar to the
existing subsection for floating point registers.  Since the
floating point registers are always present (and thus migrated),
we can skip them when performing the migration of the vector
registers which may or may not be present.

Suggested-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: Add vector registers to ELF dump
Eric Farman [Thu, 29 May 2014 18:54:26 +0000 (14:54 -0400)]
s390x: Add vector registers to ELF dump

Create ELF notes for the vector registers where applicable, so that
their contents can be examined by utilities such as crash or readelf.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agolinux/elf.h update
Eric Farman [Wed, 12 Nov 2014 19:22:55 +0000 (14:22 -0500)]
linux/elf.h update

Sync with kernel elf.h updates to get s390x vector register definitions.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: Add vector registers to HMP output
Eric Farman [Thu, 29 May 2014 17:50:37 +0000 (13:50 -0400)]
s390x: Add vector registers to HMP output

There are mechanisms to dump registers via the qemu HMP interface,
such as the "info registers" command.  Expand this output to dump
the new vector registers.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: gdb updates for vector registers
Eric Farman [Tue, 3 Jun 2014 12:42:18 +0000 (08:42 -0400)]
s390x: gdb updates for vector registers

gdb allows registers to be displayed/modified, and is being updated
to account for the new vector registers.  Mirror these changes in
the gdb stub in qemu so that this can be performed when gdb is
attached to the qemu gdbserver.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agogdb-xml: Include XML for s390 vector registers
Eric Farman [Tue, 18 Nov 2014 22:03:02 +0000 (17:03 -0500)]
gdb-xml: Include XML for s390 vector registers

Include the vector registers XML file that is provided by gdb,
and can be used by the qemu gdbserver interface.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: Store Additional Status SIGP order
Eric Farman [Wed, 14 Jan 2015 14:57:16 +0000 (09:57 -0500)]
s390x: Store Additional Status SIGP order

Add handling for the Store Additional Status at Address order
that exists for the Signal Processor (SIGP) instruction.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: Vector Register IOCTLs
Eric Farman [Mon, 18 Aug 2014 19:33:39 +0000 (15:33 -0400)]
s390x: Vector Register IOCTLs

Handle the actual syncing of the vector registers with kernel space,
via the get/put register IOCTLs.

The vector registers that were introduced with the z13 overlay
the existing floating point registers.  FP registers 0-15 are
the high-halves of vector registers 0-15.  Thus, remove the
freg fields and replace them with the equivalent vector field
to avoid errors in duplication.  Moreover, synchronize either the
vector registers via kvm_sync_regs, or floating point registers
via the GET/SET FPU IOCTLs.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agos390x: Common access to floating point registers
Eric Farman [Thu, 7 May 2015 18:35:44 +0000 (14:35 -0400)]
s390x: Common access to floating point registers

Provide a routine to access the correct floating point register,
to simplify future expansion.

Suggested-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agonet/net: Record usage status of mac address
Shannon Zhao [Thu, 21 May 2015 09:44:48 +0000 (17:44 +0800)]
net/net: Record usage status of mac address

Currently QEMU dynamically generates mac address for the NIC which
doesn't specify the mac address. But when we hotplug a NIC without
specifying mac address, the mac address will increase for the same NIC
along with hotplug and hot-unplug, and at last it will overflow. And if
we codeplug one NIC with mac address e.g. "52:54:00:12:34:56", then
hotplug one NIC without specifying mac address and the mac address of
the hotplugged NIC is duplicate of "52:54:00:12:34:56".

This patch add a mac_table to record the usage status and free the mac
address when the NIC is unrealized.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Improve -netdev/netdev_add/-net/... tap error reporting
Markus Armbruster [Fri, 15 May 2015 11:59:03 +0000 (13:59 +0200)]
tap: Improve -netdev/netdev_add/-net/... tap error reporting

When -netdev tap fails, it first reports a specific error, then a
generic one, like this:

    $ qemu-system-x86_64 -netdev tap,id=foo
    qemu-system-x86_64: -netdev tap,id=foo: could not configure /dev/net/tun: Operation not permitted
    qemu-system-x86_64: -netdev tap,id=foo: Device 'tap' could not be initialized

With the command line, the messages go to stderr.  In HMP, they go to
the monitor.  In QMP, the second one becomes the error reply, and the
first one goes to stderr.

Convert net_init_tap() to Error.  This suppresses the unwanted second
message, and makes the specific error the QMP error reply.

[Dropped duplicate "and" from error message as suggested by Eric Blake:
"ifname=, script=, downscript=, and vnet_hdr=, "
"queues=, and vhostfds= are invalid with helper="
--Stefan]

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-16-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Finish conversion of tap_open() to Error
Markus Armbruster [Fri, 15 May 2015 11:59:02 +0000 (13:59 +0200)]
tap: Finish conversion of tap_open() to Error

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-15-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap-solaris: Convert tap_open() to Error
Markus Armbruster [Fri, 15 May 2015 11:59:01 +0000 (13:59 +0200)]
tap-solaris: Convert tap_open() to Error

Fixes inappropriate use of syslog().

Not fixed: leaks on error paths, suspicious non-fatal errors.  FIXMEs
added instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-14-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap-bsd: Convert tap_open() to Error
Markus Armbruster [Fri, 15 May 2015 11:59:00 +0000 (13:59 +0200)]
tap-bsd: Convert tap_open() to Error

Fixes inappropriate use of stderr in monitor command handler.

While there, improve some of the messages a bit.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-13-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap-linux: Convert tap_open() to Error
Markus Armbruster [Fri, 15 May 2015 11:58:59 +0000 (13:58 +0200)]
tap-linux: Convert tap_open() to Error

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-12-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Permit incremental conversion of tap_open() to Error
Markus Armbruster [Fri, 15 May 2015 11:58:58 +0000 (13:58 +0200)]
tap: Permit incremental conversion of tap_open() to Error

Convert the trivial ones immediately: tap-aix and tap-haiku.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-11-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Convert launch_script() to Error
Markus Armbruster [Fri, 15 May 2015 11:58:57 +0000 (13:58 +0200)]
tap: Convert launch_script() to Error

Fixes inappropriate use of stderr in monitor command handler.

While there, improve the messages some.

[Fixed Error **err -> Error *err local variable that broke the build.
--Stefan]

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-10-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Convert net_init_tap_one() to Error
Markus Armbruster [Fri, 15 May 2015 11:58:56 +0000 (13:58 +0200)]
tap: Convert net_init_tap_one() to Error

[Dropped %s from "tap: open vhost char device failed: %s" since
error_setg_errno() already prints a human-readable error string and
there is no format string argument.
--Stefan]

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-9-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Convert tap_set_sndbuf() to Error
Markus Armbruster [Fri, 15 May 2015 11:58:55 +0000 (13:58 +0200)]
tap: Convert tap_set_sndbuf() to Error

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-8-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: Improve -netdev/netdev_add/-net/... bridge error reporting
Markus Armbruster [Fri, 15 May 2015 11:58:54 +0000 (13:58 +0200)]
tap: Improve -netdev/netdev_add/-net/... bridge error reporting

When -netdev bridge fails, it first reports a specific error, then a
generic one, like this:

    $ qemu-system-x86_64 -netdev bridge,id=foo
    failed to launch bridge helper
    qemu-system-x86_64: -netdev bridge,id=foo: Device 'bridge' could not be initialized

The first message goes to stderr.  Wrong for HMP, because errors need
to go to the monitor there.

The second message goes to stderr for -netdev, to the monitor for HMP
netdev_add, and becomes the error reply for QMP netdev_add.

Convert net_bridge_run_helper() to Error, and propagate its errors
through net_init_bridge().  This ensures the error gets reported where
the user is, and suppresses the unwanted second message.

While there, improve the error messages a bit.

The above example becomes:

    $ qemu-system-x86_64 -netdev bridge,id=foo
    qemu-system-x86_64: -netdev bridge,id=foo: bridge helper failed

net_init_tap() also uses net_bridge_run_helper().  Propagate its
errors there as well.  Improves reporting these errors with -netdev
tap & friends.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-7-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agotap: net_tap_fd_init() can't fail, drop dead error handling
Markus Armbruster [Fri, 15 May 2015 11:58:53 +0000 (13:58 +0200)]
tap: net_tap_fd_init() can't fail, drop dead error handling

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-6-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agonet/dump: Improve -net/host_net_add dump error reporting
Markus Armbruster [Fri, 15 May 2015 11:58:52 +0000 (13:58 +0200)]
net/dump: Improve -net/host_net_add dump error reporting

When -net dump fails, it first reports a specific error, then a
generic one, like this:

    $ qemu-system-x86_64 -net dump,id=foo,file=/eperm
    qemu-system-x86_64: -net dump,id=foo,file=/eperm: -net dump: can't open /eperm
    qemu-system-x86_64: -net dump,id=foo,file=/eperm: Device 'dump' could not be initialized

Convert net_init_tap() to Error.  This suppresses the unwanted second
message.

Improve the error messages to include strerror(errno) where
appropriate.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-5-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agonet: Improve -net nic error reporting
Markus Armbruster [Fri, 15 May 2015 11:58:51 +0000 (13:58 +0200)]
net: Improve -net nic error reporting

When -net nic fails, it first reports a specific error, then a generic
one, like this:

    $ qemu-system-x86_64 -net nic,netdev=nonexistent
    qemu-system-x86_64: -net nic,netdev=nonexistent: netdev 'nonexistent' not found
    qemu-system-x86_64: -net nic,netdev=nonexistent: Device 'nic' could not be initialized

Convert net_init_nic() to Error to get rid of the unwanted second
error message.

While there, tidy up an Overcapitalized Error Message.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-4-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agonet: Permit incremental conversion of init functions to Error
Markus Armbruster [Fri, 15 May 2015 11:58:50 +0000 (13:58 +0200)]
net: Permit incremental conversion of init functions to Error

Error reporting for netdev_add is broken: the net_client_init_fun[]
report the actual errors with (at best) error_report(), and their
caller net_client_init1() makes up a generic error on top.

For command line and HMP, this produces an mildly ugly error cascade.

In QMP, the actual errors go to stderr, and the generic error becomes
the command's error reply.

To fix this, we need to convert the net_client_init_fun[] to Error.

To permit fixing them one by one, add an Error ** parameter to the
net_client_init_fun[].  If the call fails without returning an Error,
make up the same generic Error as before.  But if it returns one, use
that instead.  Since none of them does so far, no functional change.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-3-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agonet: Improve error message for -net hubport a bit
Markus Armbruster [Fri, 15 May 2015 11:58:49 +0000 (13:58 +0200)]
net: Improve error message for -net hubport a bit

Type "hubport" is valid only with -netdev.  Unfortunately, that's
detected late and the error message doesn't explain why:

    $ qemu-system-i386 -net hubport,id=foo,hubid=0
    qemu-system-i386: -net hubport,id=foo,hubid=0: Device 'hubport' could not be initialized

Improve the error message to "Parameter 'type' expects a net type".

Not fixed: -net hubport without the parameters required by -netdev
hubport still asks for those parameters:

    $ qemu-system-i386 -net hubport
    qemu-system-i386: -net hubport: Parameter 'hubid' is missing

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-2-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agonet: Change help text to list -netdev instead of -net by default
Thomas Huth [Fri, 15 May 2015 14:58:24 +0000 (16:58 +0200)]
net: Change help text to list -netdev instead of -net by default

Looking at the output of "qemu-system-xxx -help", you easily get
the impression that "-net" is the preferred way instead of "-netdev"
to specify host network interface, since the "-net" option is
omnipresent but the "-netdev" option is only listed as a one-liner
at the end. This is ugly since "-net" is considered as legacy and
even might be removed one day. Thus, this patch switches the output
to explain the host network interfaces with the "-netdev" option
instead, moving the old "-net" option into some few lines at
the end.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-id: 1431701904-12230-1-git-send-email-thuth@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9 years agoMerge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging
Peter Maydell [Tue, 26 May 2015 10:31:03 +0000 (11:31 +0100)]
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging

# gpg: Signature made Fri May 22 20:58:44 2015 BST using RSA key ID AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* remotes/jnsnow/tags/ide-pull-request:
  ahci: do not remap clb/fis unconditionally
  macio: move unaligned DMA write code into separate pmac_dma_write() function
  macio: move unaligned DMA read code into separate pmac_dma_read() function
  qtest: pre-buffer hex nibs
  libqos/ahci: Swap memread/write with bufread/write
  qtest: add memset to qtest protocol
  qtest: Add base64 encoded read/write
  qtest: allow arbitrarily long sends
  qtest/ahci: add migrate halted dma test
  qtest/ahci: add halted dma test
  qtest/ahci: add flush migrate test
  qtest/ahci: add migrate dma test
  qtest/ahci: Add migration test
  ich9/ahci: Enable Migration
  libqos: Add migration helpers
  libqos/ahci: Fix sector set method
  libqos/ahci: Add halted command helpers
  glib: remove stale compat functions
  configure: require glib 2.22

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoahci: do not remap clb/fis unconditionally
John Snow [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
ahci: do not remap clb/fis unconditionally

This continues the IOMMU fix from 2.3, where we should not attempt
to remap the CLB or FIS RX buffers if the AHCI device is currently
running.

The same applies to migration: keep our mitts off these registers
unless the device is supposed to be on.

Does not impact backwards compatibility for the AHCI device.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1431470173-30847-2-git-send-email-jsnow@redhat.com

9 years agomacio: move unaligned DMA write code into separate pmac_dma_write() function
Mark Cave-Ayland [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
macio: move unaligned DMA write code into separate pmac_dma_write() function

Similarly switch the macio IDE routines over to use the new function and
tidy-up the remaining code as required.

[Maintainer edit: printf format codes adjusted for 32/64bit. --js]

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: John Snow <jsnow@redhat.com>
Message-id: 1425939893-14404-3-git-send-email-mark.cave-ayland@ilande.co.uk
Signed-off-by: John Snow <jsnow@redhat.com>
9 years agomacio: move unaligned DMA read code into separate pmac_dma_read() function
Mark Cave-Ayland [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
macio: move unaligned DMA read code into separate pmac_dma_read() function

This considerably helps simplify the complexity of the macio read routines and
by switching macio CDROM accesses to use the new code, fixes the issue with
the CDROM device being detected intermittently by Darwin/OS X.

[Maintainer edit: printf format codes adjusted for 32/64bit. --js]

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ailande.co.uk>
Acked-by: John Snow <jsnow@redhat.com>
Message-id: 1425939893-14404-2-git-send-email-mark.cave-ayland@ilande.co.uk
Signed-off-by: John Snow <jsnow@redhat.com>
9 years agoqtest: pre-buffer hex nibs
John Snow [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
qtest: pre-buffer hex nibs

Instead of converting each byte one-at-a-time and then sending each byte
over the wire, use sprintf() to pre-compute all of the hex nibs into a
single buffer, then send the entire buffer all at once.

This gives a moderate speed boost to memread() and memwrite() functions.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1431021095-7558-2-git-send-email-jsnow@redhat.com

9 years agolibqos/ahci: Swap memread/write with bufread/write
John Snow [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
libqos/ahci: Swap memread/write with bufread/write

Where it makes sense, use the new faster primitives.
For generally small reads/writes such as for the PRDT
and FIS packets, stick with the more wasteful but
easier to debug memread/memwrite.

For ahci-test (before migration tests):
With this patch:
real    0m3.675s
user    0m2.582s
sys     0m1.718s

Without any qtest protocol improvements:
real    0m14.171s
user    0m12.072s
sys     0m12.527s

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1430864578-22072-6-git-send-email-jsnow@redhat.com

9 years agoqtest: add memset to qtest protocol
John Snow [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
qtest: add memset to qtest protocol

Previously, memset was just a frontend to write() and only
stupidly sent the pattern many times across the wire.

Let's not discuss who stupidly wrote it like that in the first place.
(Hint: It was me.)

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1430864578-22072-4-git-send-email-jsnow@redhat.com

9 years agoqtest: Add base64 encoded read/write
John Snow [Fri, 22 May 2015 18:13:44 +0000 (14:13 -0400)]
qtest: Add base64 encoded read/write

For larger pieces of data that won't need to be debugged and
viewing the hex nibbles is unlikely to be useful, we can encode
data using base64 instead of encoding each byte as %02x, which
leads to some space savings and faster reads/writes.

For now, the default is left as hex nibbles in memwrite() and memread().
For the purposes of making qtest io easier to read and debug, some
callers may want to specify using the old encoding format for small
patches of data where the savings from base64 wouldn't be that profound.

memwrite/memread use a data encoding that takes 2x the size of the original
buffer, but base64 uses "only" (4/3)x, so for larger buffers we can save a
decent amount of time and space.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1430864578-22072-3-git-send-email-jsnow@redhat.com

9 years agoqtest: allow arbitrarily long sends
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
qtest: allow arbitrarily long sends

qtest currently has a static buffer of size 1024 that if we
overflow, ignores the additional data silently which leads
to hangs or stream failures.

Use glib's string facilities to allow arbitrarily long data,
but split this off into a new function, qtest_sendf.

Static data can still be sent using qtest_send, which avoids
the malloc/copy overhead.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1430864578-22072-2-git-send-email-jsnow@redhat.com

9 years agoqtest/ahci: add migrate halted dma test
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
qtest/ahci: add migrate halted dma test

Test migrating a halted DMA transaction.
Resume, then test data integrity.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-10-git-send-email-jsnow@redhat.com

9 years agoqtest/ahci: add halted dma test
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
qtest/ahci: add halted dma test

If we're going to test the migration of halted DMA jobs,
we should probably check to make sure we can resume them
locally as a first step.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-9-git-send-email-jsnow@redhat.com

9 years agoqtest/ahci: add flush migrate test
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
qtest/ahci: add flush migrate test

Use blkdebug to inject an error on first flush, then attempt to flush
on the first guest. When the error halts the VM, migrate to the
second VM, and attempt to resume the command.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-8-git-send-email-jsnow@redhat.com

9 years agoqtest/ahci: add migrate dma test
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
qtest/ahci: add migrate dma test

Write to one guest, migrate, and then read from the other.
adjust ahci_io to clear any buffers it creates, so that we
can use ahci_io safely on both guests knowing we are using
empty buffers and not accidentally re-using data.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-7-git-send-email-jsnow@redhat.com

9 years agoqtest/ahci: Add migration test
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
qtest/ahci: Add migration test

Notes:

 * The migration is performed on QOSState objects.

 * The migration is performed in such a way that it does not assume
   consistency between the allocators attached to each. That is to say,
   you can use each QOSState object completely independently and then at
   an arbitrary point decide to migrate, and the destination object will
   now be consistent with the memory within the source guest. The source
   object that was migrated from will have a completely blank allocator.

ahci-test.c:
 - verify_state is added
 - ahci_migrate is added as a frontend to migrate
 - test_migrate_sanity test case is added.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-6-git-send-email-jsnow@redhat.com

9 years agoich9/ahci: Enable Migration
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
ich9/ahci: Enable Migration

Lift the flag preventing the migration of the ICH9/AHCI devices.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-5-git-send-email-jsnow@redhat.com

9 years agolibqos: Add migration helpers
John Snow [Fri, 22 May 2015 18:13:43 +0000 (14:13 -0400)]
libqos: Add migration helpers

libqos.c:
    -set_context for addressing which commands go where
    -migrate performs the actual migration

malloc.c:
    - Structure of the allocator is adjusted slightly with
      a second-tier malloc to make swapping around the allocators
      easy when we "migrate" the lists from the source to the destination.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-4-git-send-email-jsnow@redhat.com

9 years agolibqos/ahci: Fix sector set method
John Snow [Fri, 22 May 2015 18:13:42 +0000 (14:13 -0400)]
libqos/ahci: Fix sector set method

|| probably does not mean the same thing as |.

Additionally, allow users to submit a prd_size of 0
to indicate that they'd like to continue using the default.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-3-git-send-email-jsnow@redhat.com

9 years agolibqos/ahci: Add halted command helpers
John Snow [Fri, 22 May 2015 18:13:42 +0000 (14:13 -0400)]
libqos/ahci: Add halted command helpers

Sometimes we want a command to halt the VM instead
of complete successfully, so it'd be nice to let the
libqos/ahci functions cope with such scenarios.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 1430417242-11859-2-git-send-email-jsnow@redhat.com

9 years agoglib: remove stale compat functions
John Snow [Fri, 22 May 2015 18:13:42 +0000 (14:13 -0400)]
glib: remove stale compat functions

Since we're bumping the version to 2.22+,
remove the now-stale compat functions.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1431469140-22208-2-git-send-email-jsnow@redhat.com

9 years agoconfigure: require glib 2.22
John Snow [Fri, 22 May 2015 18:13:42 +0000 (14:13 -0400)]
configure: require glib 2.22

This provides g_ptr_array_new_with_free_func, as well as a few
other functions that we've been hacking around in glib-compat.h.
Cleaning up the compatibility headers will come later.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1431469140-22208-2-git-send-email-jsnow@redhat.com

9 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Fri, 22 May 2015 16:20:09 +0000 (17:20 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer core and image format patches

# gpg: Signature made Fri May 22 16:21:03 2015 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (22 commits)
  MAINTAINERS: Split "Block QAPI, monitor, command line" off core
  MAINTAINERS: Add header files to Block Layer Core section
  tests: add test case for encrypted qcow2 read/write
  qemu-io: prompt for encryption keys when required
  util: allow \n to terminate password input
  util: move read_password method out of qemu-img into osdep/oslib
  qcow2/qcow: protect against uninitialized encryption key
  qemu-iotests: Make debugging python tests easier
  qemu-iotests: qemu-img info on afl VMDK image with a huge capacity
  block: Detect multiplication overflow in bdrv_getlength
  qemu-io: Use getopt() correctly
  qcow2: style fixes in qcow2-cache.c
  qcow2: make qcow2_cache_put() a void function
  qcow2: use a hash to look for entries in the L2 cache
  qcow2: remove qcow2_cache_find_entry_to_replace()
  qcow2: use an LRU algorithm to replace entries from the L2 cache
  qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty()
  qcow2: use one single memory block for the L2/refcount cache tables
  vmdk: Fix overflow if l1_size is 0x20000000
  vmdk: Fix next_cluster_sector for compressed write
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMerge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-20150522' into...
Peter Maydell [Fri, 22 May 2015 15:22:42 +0000 (16:22 +0100)]
Merge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-20150522' into staging

TriCore v1.6.1 ISA and missing v1.6 instructions

# gpg: Signature made Fri May 22 16:02:45 2015 BST using RSA key ID 6B69CA14
# gpg: Good signature from "Bastian Koppelmann <kbastian@mail.uni-paderborn.de>"

* remotes/bkoppelmann/tags/pull-tricore-20150522:
  target-tricore: add RR_DIV and RR_DIV_U instructions of the v1.6 ISA
  target-tricore: add FRET instructions of the v1.6 ISA
  target-tricore: add FCALL instructions of the v1.6 ISA
  target-tricore: add SYS_RESTORE instruction of the v1.6 ISA
  target-tricore: add RR_CRC32 instruction of the v1.6.1 ISA
  target-tricore: add SWAPMSK instructions of the v1.6.1 ISA
  target-tricore: add CMPSWP instructions of the v1.6.1 ISA
  target-tricore: Add SRC_MOV_E instruction of the v1.6 ISA
  target-tricore: introduce ISA v1.6.1 feature
  target-tricore: Add ISA v1.3.1 cpu and fix tc1796 to using v1.3

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9 years agoMAINTAINERS: Split "Block QAPI, monitor, command line" off core
Markus Armbruster [Wed, 20 May 2015 11:23:46 +0000 (13:23 +0200)]
MAINTAINERS: Split "Block QAPI, monitor, command line" off core

Kevin and Stefan asked me to take care of this part.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoMAINTAINERS: Add header files to Block Layer Core section
Kevin Wolf [Wed, 20 May 2015 10:03:17 +0000 (12:03 +0200)]
MAINTAINERS: Add header files to Block Layer Core section

Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agotests: add test case for encrypted qcow2 read/write
Daniel P. Berrange [Tue, 12 May 2015 16:09:22 +0000 (17:09 +0100)]
tests: add test case for encrypted qcow2 read/write

Add a simple test case for qemu-iotests that covers read/write
with encrypted qcow2 files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqemu-io: prompt for encryption keys when required
Daniel P. Berrange [Tue, 12 May 2015 16:09:21 +0000 (17:09 +0100)]
qemu-io: prompt for encryption keys when required

The qemu-io tool does not check if the image is encrypted so
historically would silently corrupt the sectors by writing
plain text data into them instead of cipher text. The earlier
commit turns this mistake into a fatal abort, so check for
encryption and prompt for key when required.

This enables us to add unit tests to ensure we don't break
the ability of qemu-img to convert existing encrypted qcow2
files into a non-encrypted format.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoutil: allow \n to terminate password input
Daniel P. Berrange [Tue, 12 May 2015 16:09:20 +0000 (17:09 +0100)]
util: allow \n to terminate password input

The qemu_read_password() method looks for \r to terminate the
reading of the a password. This is what will be seen when
reading the password from a TTY. When scripting though, it is
useful to be able to send the password via a pipe, in which
case we must look for \n to terminate password input.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoutil: move read_password method out of qemu-img into osdep/oslib
Daniel P. Berrange [Tue, 12 May 2015 16:09:19 +0000 (17:09 +0100)]
util: move read_password method out of qemu-img into osdep/oslib

The qemu-img.c file has a read_password() method impl that is
used to prompt for passwords on the console, with impls for
POSIX and Windows. This will be needed by qemu-io.c too, so
move it into the QEMU osdep/oslib files where it can be shared
without code duplication

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqcow2/qcow: protect against uninitialized encryption key
Daniel P. Berrange [Tue, 12 May 2015 16:09:18 +0000 (17:09 +0100)]
qcow2/qcow: protect against uninitialized encryption key

When a qcow[2] file is opened, if the header reports an
encryption method, this is used to set the 'crypt_method_header'
field on the BDRVQcow[2]State struct, and the 'encrypted' flag
in the BDRVState struct.

When doing I/O operations, the 'crypt_method' field on the
BDRVQcow[2]State struct is checked to determine if encryption
needs to be applied.

The crypt_method_header value is copied into crypt_method when
the bdrv_set_key() method is called.

The QEMU code which opens a block device is expected to always
do a check

   if (bdrv_is_encrypted(bs)) {
       bdrv_set_key(bs, ....key...);
   }

If code forgets to do this, then 'crypt_method' is never set
and so when I/O is performed, QEMU writes plain text data
into a sector which is expected to contain cipher text, or
when reading, will return cipher text instead of plain
text.

Change the qcow[2] code to consult bs->encrypted when deciding
whether encryption is required, and assert(s->crypt_method)
to protect against cases where the caller forgets to set the
encryption key.

Also put an assert in the set_key methods to protect against
the case where the caller sets an encryption key on a block
device that does not have encryption

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqemu-iotests: Make debugging python tests easier
Fam Zheng [Mon, 18 May 2015 01:39:12 +0000 (09:39 +0800)]
qemu-iotests: Make debugging python tests easier

Adding "-d" option. The output goes to "tee" so it appears in your
console. Also, raise the verbosity of unnitest runner.

When testing a topic branch, it's possible that a bug introduced by a
code change makes the python test case hang, with debug output, it is
much easier to locate the problem.

This can also be helpful if you want to watch the progress of a python
test, it offers you a way to sense the speed of each test case method
you're writing.

Note: because there is no easy way to get *both* the verbose output and
the output expected by ./check comparison, the case would always fail
with an "output mismatch". The sole purpose of using this option is
giving developers a quick way to debug when things go wrong.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqemu-iotests: qemu-img info on afl VMDK image with a huge capacity
Fam Zheng [Fri, 15 May 2015 08:36:06 +0000 (16:36 +0800)]
qemu-iotests: qemu-img info on afl VMDK image with a huge capacity

The image is contributed by Richard W.M. Jones.

Cc: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoblock: Detect multiplication overflow in bdrv_getlength
Fam Zheng [Fri, 15 May 2015 08:36:05 +0000 (16:36 +0800)]
block: Detect multiplication overflow in bdrv_getlength

Bogus image may have a large total_sectors that will overflow the
multiplication. For cleanness, fix the return code so the error message
will be meaningful.

Reported-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqemu-io: Use getopt() correctly
Eric Blake [Tue, 12 May 2015 15:10:56 +0000 (09:10 -0600)]
qemu-io: Use getopt() correctly

POSIX says getopt() returns -1 on completion.  While Linux happens
to define EOF as -1, this definition is not required by POSIX, and
there may be platforms where checking for EOF instead of -1 would
lead to an infinite loop.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqcow2: style fixes in qcow2-cache.c
Alberto Garcia [Mon, 11 May 2015 12:54:59 +0000 (15:54 +0300)]
qcow2: style fixes in qcow2-cache.c

Fix pointer declaration to make it consistent with the rest of the
code.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9 years agoqcow2: make qcow2_cache_put() a void function
Alberto Garcia [Mon, 11 May 2015 12:54:58 +0000 (15:54 +0300)]
qcow2: make qcow2_cache_put() a void function

This function never receives an invalid table pointer, so we can make
it void and remove all the error checking code.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>