]> git.proxmox.com Git - qemu.git/log
qemu.git
11 years agotarget-mips: Use TCG registers for the FPU.
Richard Henderson [Tue, 9 Oct 2012 19:53:19 +0000 (21:53 +0200)]
target-mips: Use TCG registers for the FPU.

With normal FP, this doesn't have much affect on the generated code,
because most of the FP operations are not CONST/PURE, and so we spill
registers in about the same frequency as the explicit load/stores.

But with Loongson multimedia instructions, which are all integral and
whose helpers are in fact CONST+PURE, this greatly improves the code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: remove compatiblity call flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
tcg: remove compatiblity call flags

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-xtensa: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-xtensa: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-sparc: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-sparc: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Blue Swirl <blauwirbel@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-sh4: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-sh4: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-s390x: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-s390x: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Alexander Graf <agraf@suse.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-ppc: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-ppc: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Alexander Graf <agraf@suse.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-mips: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-microblaze: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-microblaze: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-i386: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-i386: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-cris: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-cris: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-arm: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-arm: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Paul Brook <paul@codesourcery.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-alpha: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-alpha: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: rework TCG helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: rework TCG helper flags

The current helper flags, TCG_CALL_CONST and TCG_CALL_PURE might be
confusing and doesn't provide enough granularity for some helpers (FP
helpers for example).

This patch changes them into the following helpers flags:
- TCG_CALL_NO_READ_GLOBALS means that the helper does not read globals,
  either directly or via an exception. They will not be saved to their
  canonical location before calling the helper.
- TCG_CALL_NO_WRITE_GLOBALS means that the helper does not modify any
  globals. They will only be saved to their canonical locations before
  calling helpers, but they won't be reloaded afterwise.
- TCG_CALL_NO_SIDE_EFFECTS means that the call to the function is
  removed if the return value is not used.

It provides convenience flags, to avoid helper definitions longer than
80 characters. It also provides compatibility flags, and updates the
documentation.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: synchronize globals for ops with side effects
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: synchronize globals for ops with side effects

Operations with side effects (in practice qemu_ld/st ops), only need to
synchronize globals to make sure the CPU state is consistent in case of
exception.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: forbid ld/st function to modify globals
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: forbid ld/st function to modify globals

Mapping a memory address using a global and accessing it through
ld/st operations is currently broken. As it doesn't make any sense
to do that performance wise, let's forbid that.

Update the TCG documentation, and remove partial support for that.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: fix some op flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: fix some op flags

Some branch related ops are marked with TCG_OPF_SIDE_EFFECTS, some other
not. In practice they don't need to, as they are all marked with
TCG_OPF_BB_END, which is handled specifically in all the code.

The call op is marked as TCG_OPF_SIDE_EFFECTS, which might be not true
as there is are specific flags (TCG_CALL_CONST and TCG_CALL_PURE) for
specifying that. On the other hand it always clobber arguments, so mark
it as such even if the call op is handled in a different code path.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: don't explicitly save globals and temps
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: don't explicitly save globals and temps

The liveness analysis ensures that globals and temps are at the correct
state at a basic block end or with an op with side effects. Avoid
looping on all temps, this can be time consuming on targets with a lot
of globals. Keep an assert in debug mode.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: start with local temps in TEMP_VAL_MEM state
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: start with local temps in TEMP_VAL_MEM state

Start with local temps in TEMP_VAL_MEM state, to make possible a later
check that all the temps are correctly saved back to memory.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: always mark dead input arguments as dead
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: always mark dead input arguments as dead

Always mark dead input arguments as dead, even if the op is at the basic
block end. This will allow to check that all temps are correctly saved.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: rewrite tcg_reg_alloc_mov()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: rewrite tcg_reg_alloc_mov()

Now that the liveness analysis provides more information, rewrite
tcg_reg_alloc_mov(). This changes the behaviour about propagating
constants and memory accesses. We now take the assumption that once
a value is loaded into a register (from memory or from a constant),
it's better to keep it there than to reload it later. This assumption
is now always almost correct given that we are now sure the
corresponding temp is going to be used later (otherwise it would have
been synchronized and marked as dead already). The assumption is wrong
if one of the op after clobbers some registers including the one
of the holding the temp (this can be avoided by allocating clobbered
registers last, which is what most TCG target do), or in case of lack
of available register.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: improve tcg_reg_alloc_movi()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: improve tcg_reg_alloc_movi()

Now that the liveness analysis might mark some output temps as dead, call
temp_dead() if needed.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: rework liveness analysis
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: rework liveness analysis

Rework the liveness analysis by tracking temps that need to go back to
memory in addition to dead temps tracking. This allows to mark output
arguments as "need sync", and to synchronize them back to memory as soon
as they are not written anymore. This way even arguments mapping to
globals can be marked as "dead", avoiding moves to a new register when
input and outputs are aliased.

In addition it means that registers are freed as soon as temps are not
used anymore, instead of waiting for a basic block end or an op with side
effects. This reduces register spilling especially on CPUs with few
registers, and spread the mov over all the TB, increasing the
performances on in-order CPUs.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: sync output arguments on liveness request
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: sync output arguments on liveness request

Synchronize an output argument when requested by the liveness analysis.
This is needed so that the temp can be declared dead later.

For that, add a new op_sync_args table in which each bit tells if the
corresponding output argument needs to be synchronized with the memory.
Pass it to the tcg_reg_alloc_* functions, and honor this bit. We need to
synchronize the argument before marking it as dead, and we have to make
sure all the infos about the temp are correctly filled.

At the same time change some types from unsigned int to uint16_t when
passing op_dead_args.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: add temp_sync()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:06 +0000 (21:53 +0200)]
tcg: add temp_sync()

Add a new function temp_sync() to synchronize the canonical location
of a temp with the value in the corresponding register, but without
freeing the associated register. Rewrite temp_save() to call
temp_sync() followed by temp_dead().

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: add tcg_reg_sync()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:06 +0000 (21:53 +0200)]
tcg: add tcg_reg_sync()

Add a new function tcg_reg_sync() to synchronize the canonical location
of a temp with the value in the associated register, but without freeing
it. Rewrite tcg_reg_free() to first call tcg_reg_sync() and then to free
the register.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: add temp_dead()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:06 +0000 (21:53 +0200)]
tcg: add temp_dead()

A lot of code is duplicated to mark a temporary as dead. Replace it
by temp_dead(), which in addition marks the temp as saved in memory
for globals and local temps, instead of doing this a posteriori in
temp_save().

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg/i386: remove ld/st third argument register constraint
Aurelien Jarno [Sat, 20 Oct 2012 15:31:44 +0000 (17:31 +0200)]
tcg/i386: remove ld/st third argument register constraint

On x86_64, remove the constraint on the third argument register which
is not needed:
 - For loads the helper arguments are env, addr, mem_idx. The addr
   value should not be in the two first argument registers as they are
   used in tcg_out_tlb_load().
 - For stores the helper arguments are env, addr, data, mem_idx.
   The addr and data values should not be in the two first argument
   registers as they are used in tcg_out_tlb_load(). The data value
   should also not be in the two first argument registers, but could
   be in the third argument register in which case it would be already
   loaded at the right location.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg/i386: remove suboptimal register shifting
Aurelien Jarno [Sat, 20 Oct 2012 15:31:44 +0000 (17:31 +0200)]
tcg/i386: remove suboptimal register shifting

Now that CONFIG_TCG_PASS_AREG0 has been removed, it's easier to get
an optimal code for the load/store functions.

First swap the two registers used in tcg_out_tlb_load() so that the
address end-up in the second register instead of the first one. Adjust
tcg_out_qemu_ld() and tcg_out_qemu_st() to respectively call
tcg_out_qemu_ld_direct() and tcg_out_qemu_st_direct() with the correct
registers. Then replace the register shifting by direct load of the
arguments.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agohw/xtensa_sim: get rid of intermediate xtensa_sim_init
Max Filippov [Thu, 25 Oct 2012 11:37:52 +0000 (15:37 +0400)]
hw/xtensa_sim: get rid of intermediate xtensa_sim_init

Remove xtensa_sim_init that only explodes machine init args, rename
sim_init to xtensa_sim_init.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agohw/xtensa_lx60: don't prematurely explode QEMUMachineInitArgs
Max Filippov [Thu, 25 Oct 2012 11:37:51 +0000 (15:37 +0400)]
hw/xtensa_lx60: don't prematurely explode QEMUMachineInitArgs

Don't explode QEMUMachineInitArgs before passing it to lx_init.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoMakefile: Forbid out-of-tree build from a source tree that has been built in
Peter Maydell [Fri, 19 Oct 2012 13:54:23 +0000 (14:54 +0100)]
Makefile: Forbid out-of-tree build from a source tree that has been built in

If we try to do an out-of-tree build but the source tree we're building from
has been used in the past for an in-tree build then things will go
confusingly wrong. Specifically, some parts of the build process will pull
in generated files from the old in-tree build (because SRC_PATH is on
the vpath). Diagnose this situation so we can produce a useful error
message and tell the user how to fix it (run distclean in the source tree).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotests/tcg: fix a few warnings
Catalin Patulea [Mon, 22 Oct 2012 23:18:35 +0000 (19:18 -0400)]
tests/tcg: fix a few warnings

Signed-off-by: Catalin Patulea <catalinp@google.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotarget-sparc64: disable VGA cirrus
Aurelien Jarno [Sun, 21 Oct 2012 22:50:58 +0000 (00:50 +0200)]
target-sparc64: disable VGA cirrus

OpenBIOS on sparc64 only support Standard VGA and not Cirrus VGA. Don't
build Cirrus VGA support so that it can't be selected.

This fixes the breakage introduced by commit f2898771.

Reported-by: Richard Henderson <rth@twiddle.net>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoMerge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm
Blue Swirl [Sat, 27 Oct 2012 14:21:37 +0000 (14:21 +0000)]
Merge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm

* 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm:
  target-arm: Remove out of date FIXME regarding saturating arithmetic
  target-arm: Implement abs_i32 inline rather than as a helper
  target-arm: Use TCG operation for Neon 64 bit negation
  arm-semi.c: Handle get/put_user() failure accessing arguments

11 years agoconfigure: avoid compiler warning in pipe2 detection
Bruce Rogers [Mon, 20 Aug 2012 18:45:08 +0000 (12:45 -0600)]
configure: avoid compiler warning in pipe2 detection

When building qemu-kvm for openSUSE:Factory, I am getting a
warning in the pipe2 detection performed by configure, which
prevents using --enable-werror.

Change detection code to use return value of pipe2.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoconfigure: Disable (clang) initializer-overrides warnings
Peter Maydell [Sun, 14 Oct 2012 20:00:39 +0000 (21:00 +0100)]
configure: Disable (clang) initializer-overrides warnings

Disable clang's initializer-overrides warnings, as QEMU makes significant
use of the pattern of initializing an array with a range-based default
entry like
    [0 ... 0x1ff] = { GPIO_NONE, 0 }
followed by specific entries which override that default, and clang
would otherwise warn "initializer overrides prior initialization of
this subobject" when it encountered the specific entry.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoxhci: fix usb name in caps
Gerd Hoffmann [Wed, 24 Oct 2012 14:19:21 +0000 (16:19 +0200)]
xhci: fix usb name in caps

Used to be "UTB" not "USB".

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: make number of interrupters and slots configurable
Gerd Hoffmann [Wed, 24 Oct 2012 09:49:30 +0000 (11:49 +0200)]
xhci: make number of interrupters and slots configurable

Add properties to tweak the numbers of available interrupters and slots.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: allow disabling interrupters
Gerd Hoffmann [Wed, 24 Oct 2012 07:38:08 +0000 (09:38 +0200)]
xhci: allow disabling interrupters

For secondary interrupters this is explicitly allowed in the specs.
For the primary interrupter behavior is undefined, lets be friendly
and allow disabling too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: flush endpoint context unconditinally
Gerd Hoffmann [Wed, 24 Oct 2012 08:14:16 +0000 (10:14 +0200)]
xhci: flush endpoint context unconditinally

Not updating the endpoint context in case the state didn't change is
wrong.  Other context fields might have changed, for example the
dequeue pointer in response to a CR_SET_TR_DEQUEUE command.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: fix function name in error message
Gerd Hoffmann [Wed, 24 Oct 2012 07:36:55 +0000 (09:36 +0200)]
xhci: fix function name in error message

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Use only one queue for ctrl endpoints
Hans de Goede [Wed, 24 Oct 2012 16:31:20 +0000 (18:31 +0200)]
uhci: Use only one queue for ctrl endpoints

ctrl endpoints use different pids for different phases of a control
transfer, this patch makes us use only one queue for a ctrl ep, rather
then 3.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Retry to fill the queue while waiting for td completion
Hans de Goede [Wed, 24 Oct 2012 16:31:19 +0000 (18:31 +0200)]
uhci: Retry to fill the queue while waiting for td completion

If the guest is using multiple transfers to try and keep the usb bus busy /
used at maximum efficiency, currently we would see / do the following:

1) submit transfer 1 to the device
2) submit transfer 2 to the device
3) report transfer 1 completion to guest
4) report transfer 2 completion to guest
5) submit transfer 1 to the device
6) report transfer 1 completion to guest
7) submit transfer 2 to the device
8) report transfer 2 completion to guest
etc.

So after the initial submission we would effectively only have 1 transfer
in flight, rather then 2. This is caused by us not checking the queue for
addition of new transfers by the guest (ie the resubmission of a recently
finished transfer), while waiting for a pending transfer to complete.
This patch does add a check for this, changing the sequence to:

1) submit transfer 1 to the device
2) submit transfer 2 to the device
3) report transfer 1 completion to guest
4) submit transfer 1 to the device
5) report transfer 2 completion to guest
6) submit transfer 2 to the device
etc.

Thus keeping 2 transfers in flight (most of the time, and always 1),
as intended by the guest.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Always mark a queue valid when we encounter it
Hans de Goede [Wed, 24 Oct 2012 16:31:18 +0000 (18:31 +0200)]
uhci: Always mark a queue valid when we encounter it

Before this patch we would not mark a queue valid when its head was a
non-active td. This causes us to misbehave in the following scenario:

1) queue with multiple input transfers queued
2) We hit some latency issue, causing qemu to get behind processing frames
3) When qemu gets to run again, it notices the first transfer ends short,
   marking the head td non-active
4) It now processes 32+ frames in a row without giving the guest a chance
   to run since it is behind
5) valid is decreased to 0, causing the queue to get cancelled also cancelling
   already queued up further input transfers
6) guest gets to run, notices the inactive td, cleanups up further tds
   from the short transfer, and lets the queue continue at the first td of
   the next input transfer
7) we re-start the queue, issuing the second input transfer for the *second*
   time, and any data read by the first time we issued it has been lost

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: When the guest marks a pending td non-active, cancel the queue
Hans de Goede [Wed, 24 Oct 2012 16:31:17 +0000 (18:31 +0200)]
uhci: When the guest marks a pending td non-active, cancel the queue

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Detect guest td re-use
Hans de Goede [Wed, 24 Oct 2012 16:31:16 +0000 (18:31 +0200)]
uhci: Detect guest td re-use

A td can be reused by the guest in a different queue, before we notice
the original queue has been unlinked. So search for tds by addr only, detect
guest td reuse, and cancel the original queue, this is necessary to keep our
packet ids unique.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Verify queue has not been changed by guest
Hans de Goede [Wed, 24 Oct 2012 16:31:15 +0000 (18:31 +0200)]
uhci: Verify queue has not been changed by guest

According to the spec a guest can unlink a qh, and then as soon as frindex
has changed by 1 since the unlink, assume it is idle and re-use it. However
for various reasons, we cannot simply consider a qh as unlinked if we've not
seen it for 1 frame. This means that it is possible for a guest to re-use /
restart the queue while we still see its old state. This patch adds a safety
check for this, and "early" retires queues when they were changed by the guest.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Immediately free queues on device disconnect
Hans de Goede [Wed, 24 Oct 2012 16:31:14 +0000 (18:31 +0200)]
uhci: Immediately free queues on device disconnect

There is no need to just cancel any in-flight packets, and then wait
for validate-end to clean things up, we can simply clean things up
immediately on device removal.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Store ep in UHCIQueue
Hans de Goede [Wed, 24 Oct 2012 16:31:13 +0000 (18:31 +0200)]
uhci: Store ep in UHCIQueue

This avoids the need to repeatedly lookup the device, and ep.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Make uhci_fill_queue() actually operate on an UHCIQueue
Hans de Goede [Wed, 24 Oct 2012 16:31:12 +0000 (18:31 +0200)]
uhci: Make uhci_fill_queue() actually operate on an UHCIQueue

And move its calling point to handle_td, this removes the ep_ret ugliness,
and prepates the way for further cleanups in the follow-up patches in this
patch-set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Add uhci_read_td() helper function
Hans de Goede [Wed, 24 Oct 2012 16:31:11 +0000 (18:31 +0200)]
uhci: Add uhci_read_td() helper function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Rename UHCIAsync->td to UHCIAsync->td_addr
Hans de Goede [Wed, 24 Oct 2012 16:31:10 +0000 (18:31 +0200)]
uhci: Rename UHCIAsync->td to UHCIAsync->td_addr

We use the name td both to refer to a UHCI_TD read from guest memory as
well as to refer to the guest address where a td is stored, switch over
to always use td_addr in the second case for consistency.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Move emptying of the queue's asyncs' queue to uhci_queue_free
Hans de Goede [Wed, 24 Oct 2012 16:31:09 +0000 (18:31 +0200)]
uhci: Move emptying of the queue's asyncs' queue to uhci_queue_free

Cleanup: all callers of uhci_queue_free first unconditionally cancel
all remaining asyncs in the queue, so lets move this to uhci_queue_free().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Drop unnecessary forward declaration of some static functions
Hans de Goede [Wed, 24 Oct 2012 16:31:08 +0000 (18:31 +0200)]
uhci: Drop unnecessary forward declaration of some static functions

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Don't retry on error
Hans de Goede [Wed, 24 Oct 2012 16:31:07 +0000 (18:31 +0200)]
uhci: Don't retry on error

Since we are either dealing with emulated devices, where retrying is
not going to help, or with redirected devices where the host OS will
have already retried, don't bother retrying on failed transfers.

Also move some common/indentical code out of all the error cases
into the generic error path.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: cleanup: Add an unlink call to uhci_async_cancel()
Hans de Goede [Wed, 24 Oct 2012 16:31:06 +0000 (18:31 +0200)]
uhci: cleanup: Add an unlink call to uhci_async_cancel()

All callers of uhci_async_cancel() call uhci_async_unlink() first, so
lets move the unlink call to uhci_async_cancel()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: No need to handle async completion of isoc packets
Hans de Goede [Wed, 24 Oct 2012 16:31:05 +0000 (18:31 +0200)]
uhci: No need to handle async completion of isoc packets

No devices ever return async for isoc endpoints and the core
already enforces this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Enforce iso endpoints never returing USB_RET_ASYNC
Hans de Goede [Wed, 24 Oct 2012 16:31:04 +0000 (18:31 +0200)]
usb: Enforce iso endpoints never returing USB_RET_ASYNC

ehci was already testing for this, and we depend in various places
on no devices doing this, so lets move the check for this to the
usb core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Add an int_req flag to USBPacket
Hans de Goede [Wed, 24 Oct 2012 16:14:10 +0000 (18:14 +0200)]
usb: Add an int_req flag to USBPacket

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Move short-not-ok handling to the core
Hans de Goede [Wed, 24 Oct 2012 16:14:09 +0000 (18:14 +0200)]
usb: Move short-not-ok handling to the core

After a short-not-ok packet ending short, we should not advance the queue.
Move enforcing this to the core, rather then handling it in the hcd code.

This may result in the queue now actually containing multiple input packets
(which would not happen before), and this requires special handling in
combination with pipelining, so disable pipleining for input endpoints
(for now).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Move clearing of queue on halt to the core
Hans de Goede [Wed, 24 Oct 2012 16:14:08 +0000 (18:14 +0200)]
usb: Move clearing of queue on halt to the core

hcds which queue up more then one packet at once (uhci, ehci and xhci),
must clear the queue after an error which has caused the queue to halt.

Currently this is handled as a special case inside the hcd code, this
patch instead adds an USB_RET_REMOVE_FROM_QUEUE packet result code, teaches
the 3 hcds about this and moves the clearing of the queue on a halt into
the USB core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Add USB_RET_ADD_TO_QUEUE packet result code
Hans de Goede [Wed, 24 Oct 2012 16:14:07 +0000 (18:14 +0200)]
usb: Add USB_RET_ADD_TO_QUEUE packet result code

This can be used by usb-device code which wishes to process an entire endpoint
queue at once, to do this the usb-device code returns USB_RET_ADD_TO_QUEUE
from its handle_data class method and defines a flush_ep_queue class method
to call when the hcd is done queuing up packets.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Rename __usb_packet_complete to usb_packet_complete_one
Hans de Goede [Wed, 24 Oct 2012 16:14:06 +0000 (18:14 +0200)]
usb: Rename __usb_packet_complete to usb_packet_complete_one

And make it available for use outside of core.c

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: Add a xhci_ep_nuke_one_xfer helper function
Hans de Goede [Wed, 24 Oct 2012 16:14:05 +0000 (18:14 +0200)]
xhci: Add a xhci_ep_nuke_one_xfer helper function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Retry to fill the queue while waiting for td completion
Hans de Goede [Wed, 24 Oct 2012 16:14:04 +0000 (18:14 +0200)]
ehci: Retry to fill the queue while waiting for td completion

If the guest is using multiple transfers to try and keep the usb bus busy /
used at maximum efficiency, currently we would see / do the following:

1) submit transfer 1 to the device
2) submit transfer 2 to the device
3) report transfer 1 completion to guest
4) report transfer 2 completion to guest
5) submit transfer 1 to the device
6) report transfer 1 completion to guest
7) submit transfer 2 to the device
8) report transfer 2 completion to guest
etc.

So after the initial submission we would effectively only have 1 transfer
in flight, rather then 2. This is caused by us not checking the queue for
addition of new transfers by the guest (ie the resubmission of a recently
finished transfer), while waiting for a pending transfer to complete.
This patch does add a check for this, changing the sequence to:

1) submit transfer 1 to the device
2) submit transfer 2 to the device
3) report transfer 1 completion to guest
4) submit transfer 1 to the device
5) report transfer 2 completion to guest
6) submit transfer 2 to the device
etc.

Thus keeping 2 transfers in flight (most of the time, and always 1),
as intended by the guest.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Detect going in circles when filling the queue
Hans de Goede [Wed, 24 Oct 2012 16:14:03 +0000 (18:14 +0200)]
ehci: Detect going in circles when filling the queue

For ctrl endpoints Windows (atleast Win7) creates circular td lists, so far
these were not a problem because we would stop filling the queue if altnext
was set. Since further patches in this patchset remove the altnext check this
does become a problem and we need detection for going in circles.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Speed up the timer of raising int from the async schedule
Hans de Goede [Wed, 24 Oct 2012 16:14:02 +0000 (18:14 +0200)]
ehci: Speed up the timer of raising int from the async schedule

Often the guest will queue up new packets in response to a packet, in the
async schedule with its IOC flag set, completing. By speeding up the
frame-timer, we notice these new packets earlier. This increases the
speed (MB/s) of a Linux guest reading from a USB mass storage device by a
factor of 1.15 on top of the "Improve latency of interrupt delivery"
speed-ups, both with and without input pipelining enabled.

I've not tested the speed-up of this patch without the
"Improve latency of interrupt delivery" patch.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Improve latency of interrupt delivery and async schedule scanning
Hans de Goede [Wed, 24 Oct 2012 16:14:01 +0000 (18:14 +0200)]
ehci: Improve latency of interrupt delivery and async schedule scanning

While doing various performance tests of reading from USB mass storage devices
I noticed the following::
1) When an async handled packet completes, we don't immediately report an
   interrupt to the guest, instead we wait for the frame-timer to run and
   report it from there
2) If 1) has been fixed and an async handled packet takes a while to complete,
   then async_stepdown will become a high value, which means that there
   will be a large latency before any new packets queued by the guest in
   response to the interrupt get seen

1) was done deliberately as part of commit f0ad01f92:
http://www.kraxel.org/cgit/qemu/commit/?h=usb.57&id=f0ad01f92ca02eee7cadbfd225c5de753ebd5fce
Since setting the interrupt immediately on async packet completion was causing
issues with Linux guests, I believe this recently fixed Linux bug explains
why this is happening:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=361aabf395e4a23cf554cf4ec0c0c6963b8beb01

Note that we can *not* count on this fix being present in all Linux guests!

I was hoping that the recently added support for Interrupt Threshold Control
would fix the issues with Linux guests, but adding a simple ehci_commit_irq()
call to ehci_async_bh() still caused problems with Linux guests.

The problem is, that when doing ehci_commit_irq() from ehci_async_bh(),
the "old" frindex value is used to calculate usbsts_frindex, and when
the frame-timer then runs possibly very shortly after ehci_async_bh(),
it increases the frame-timer, and thus any interrupts raised from that
frame-timer run, will also get reported to the guest immediately, rather
then being delayed to the next frame-timer run.

Luckily the solution for this is simple, this means that we need to
increase frindex before calling ehci_commit_irq() from ehci_async_bh(),
which in the end boils down to simple calling ehci_frame_timer() instead
of ehci_async_bh() from the bh.

This may seem like it causes a lot of extra work to be done, but this
is not true. Any work done from the frame-timer processing the periodic
schedule is work which then does not need to be done the next time the
frame timer runs, also the frame-timer will re-arm itself at (possibly)
a later time then it was armed for saving a vmexit at that time.

As an additional advantage moving to simply calling the frame-timer also
fixes 2) as the packet completion will set async_stepdown to 0, and the
re-arming of the timer with an async_stepdown of 0 ensures that any
newly queued up packets get seen in a reasonable amount of time.

This improves the speed (MB/s) of a Linux guest reading from a USB mass
storage device by a factor of 1.5 - 1.7 with input pipelining disabled,
and by a factor of 1.8 with input pipelining enabled.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Set int flag on a short input packet
Hans de Goede [Wed, 24 Oct 2012 16:14:00 +0000 (18:14 +0200)]
ehci: Set int flag on a short input packet

According to 4.15.1.2 an interrupt must be raised when a short packet
is received. If we don't do this it may take a significant time for
the guest to notice a short trasnfer has completed, since only the last td
will have its IOC flag set, and a short transfer may complete in an earlier
packet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Get rid of packet tbytes field
Hans de Goede [Wed, 24 Oct 2012 16:13:59 +0000 (18:13 +0200)]
ehci: Get rid of packet tbytes field

This field is used in some places to track the tbytes field of the token, but
in other places the field is used directly, use it directly everywhere for
consistency.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Move checks to continue queuing to uhci_fill_queue()
Hans de Goede [Wed, 24 Oct 2012 16:13:58 +0000 (18:13 +0200)]
uhci: Move checks to continue queuing to uhci_fill_queue()

Rather then having a special check to start queuing after the first packet,
and then another check for the other packets in uhci_fill_queue(), simply
check the previous packet beforehand in uhci_fill_queue()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Properly unmap packets on cancel / invalid pid
Hans de Goede [Wed, 24 Oct 2012 16:13:57 +0000 (18:13 +0200)]
uhci: Properly unmap packets on cancel / invalid pid

Packets with an invalid pid, or which were cancelled have
usb_packet_map() called on them on init, but not usb_packet_unmap()
before being freed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agowin32: fix broken build due to missing QEMU_MADV_HUGEPAGE
Luiz Capitulino [Wed, 24 Oct 2012 16:12:15 +0000 (14:12 -0200)]
win32: fix broken build due to missing QEMU_MADV_HUGEPAGE

Commit ad0b5321f1f797274603ebbe20108b0750baee94 forgot to add
QEMU_MADV_HUGEPAGE macros for when CONFIG_MADVISE is not defined.
This broke the build for Windows. Fix it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'bonzini/nbd-next' into staging
Anthony Liguori [Wed, 24 Oct 2012 14:39:49 +0000 (09:39 -0500)]
Merge remote-tracking branch 'bonzini/nbd-next' into staging

* bonzini/nbd-next: (30 commits)
  qmp: add NBD server commands
  block: add close notifiers
  block: prepare code for adding block notifiers
  qemu-sockets: add socket_listen, socket_connect, socket_parse
  tests: do not include tools-obj-y Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  qemu-sockets: return InetSocketAddress from inet_parse
  qapi: add socket address types
  build: add QAPI files to the tools
  vnc: drop QERR_VNC_SERVER_FAILED
  qemu-sockets: add error propagation to Unix socket functions
  qemu-sockets: add error propagation to inet_parse
  qemu-sockets: add error propagation to inet_dgram_opts
  qemu-sockets: add error propagation to inet_connect_addr
  qemu-sockets: include strerror or gai_strerror output in error messages
  vnc: add error propagation to vnc_display_open
  vnc: reorganize code for reverse mode
  vnc: introduce a single label for error returns
  vnc: avoid Yoda conditionals
  qemu-ga: ask and print error information from qemu-sockets
  nbd: ask and print error information from qemu-sockets
  ...

11 years agomigration: go to paused state after finishing incoming migration with -S
Paolo Bonzini [Fri, 19 Oct 2012 14:45:24 +0000 (16:45 +0200)]
migration: go to paused state after finishing incoming migration with -S

At the end of migration the machine has started already, and cannot be
destroyed without losing the guest's data.  Hence, prelaunch is the
wrong state.  Go to the paused state instead.  QEMU would reach that
state anyway (after running the guest for the blink of an eye) if the
"stop" command had been received after the start of migration.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
11 years agoqmp: handle stop/cont in INMIGRATE state
Paolo Bonzini [Tue, 23 Oct 2012 12:54:21 +0000 (14:54 +0200)]
qmp: handle stop/cont in INMIGRATE state

Right now, stop followed by an incoming migration will let the
virtual machine start.  cont before an incoming migration instead
will fail.

This is bad because the actual behavior is not predictable; it is
racy with respect to the start of the incoming migration.  That's
because incoming migration is blocking, and thus will delay the
processing of stop/cont until the end of the migration.

In addition, there's nothing that really prevents the user from
typing the block device's passwords before incoming migration is
done, so returning the DeviceEncrypted error is also helpful in
the QMP case.

Both things can be fixed by just toggling the autostart variable when
stop/cont are called in INMIGRATE state.

Note that libvirt is currently working around the race by looping
if the MigrationExpected answer is returned.  After this patch, the
command will return right away without ever raising an error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
11 years agohmp: fix info cpus for sparc targets
Aurelien Jarno [Fri, 19 Oct 2012 21:19:19 +0000 (23:19 +0200)]
hmp: fix info cpus for sparc targets

On sparc targets, info cpus returns this kind of output:

| info cpus
| * CPU #0: pc=0x0000000000424d18pc=0x0000000000424d18npc=0x0000000000424d1c thread_id=19460

pc is printed twice, there is no space between pc, pc and npc.

With this patch, pc is not printed anymore when has_npc is set. In addition
the space is printed before pc/nip/npc/PC instead of after the colon so that
multiple prints are possible. This result on the following kind of input on
sparc targets:

| info cpus
| * CPU #0: pc=0x0000000000424d18 npc=0x0000000000424d1c thread_id=19460

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
11 years agotarget-arm: Remove out of date FIXME regarding saturating arithmetic
Peter Maydell [Fri, 19 Oct 2012 04:23:05 +0000 (04:23 +0000)]
target-arm: Remove out of date FIXME regarding saturating arithmetic

Remove an out of date FIXME regarding the saturating arithmetic helpers:
we now do pass a pointer to CPUARMState to these helpers, and since
the AREG0 changes went in there is no difference between helper.c
and op_helper.c and therefore no point in moving the functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11 years agotarget-arm: Implement abs_i32 inline rather than as a helper
Peter Maydell [Thu, 18 Oct 2012 16:40:41 +0000 (17:40 +0100)]
target-arm: Implement abs_i32 inline rather than as a helper

Implement abs_i32 inline (with movcond) rather than using a helper
function.

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11 years agotarget-arm: Use TCG operation for Neon 64 bit negation
Peter Maydell [Thu, 18 Oct 2012 15:58:52 +0000 (16:58 +0100)]
target-arm: Use TCG operation for Neon 64 bit negation

Use the TCG operation to do Neon 64 bit negations rather than calling
a helper routine for it.

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11 years agoarm-semi.c: Handle get/put_user() failure accessing arguments
Peter Maydell [Sun, 14 Oct 2012 09:52:27 +0000 (09:52 +0000)]
arm-semi.c: Handle get/put_user() failure accessing arguments

Rework the handling of arguments to ARM semihosting calls so that we
handle a possible failure return from get_user_ual() or put_user_ual().
(This incidentally silences a lot of warnings from clang about
"expression result unused").

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11 years agoosdep: Less restrictive F_SEFL in qemu_dup_flags()
Corey Bryant [Thu, 18 Oct 2012 20:41:04 +0000 (16:41 -0400)]
osdep: Less restrictive F_SEFL in qemu_dup_flags()

qemu_dup_flags() currently limits the flags that can be set on the
fcntl() F_SETFL call to those that we currently know can be set with
fcntl() F_SETFL.  The problem with this is that it will prevent use
of new flags in the future without a code update.

This patch relaxes the checking and lets fcntl() determine the flags
it can set.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add testcases for mirroring on-source-error/on-target-error
Paolo Bonzini [Tue, 23 Oct 2012 14:39:23 +0000 (16:39 +0200)]
qemu-iotests: add testcases for mirroring on-source-error/on-target-error

The new options are tested with blkdebug on both the source and the
target.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqmp: add pull_event function
Paolo Bonzini [Thu, 18 Oct 2012 14:49:29 +0000 (16:49 +0200)]
qmp: add pull_event function

This function is unlike get_events in that it makes it easy to process
one event at a time.  This is useful in the mirroring test cases, where
we want to process just one event (BLOCK_JOB_ERROR) and leave the others
to a helper function.

Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agomirror: add support for on-source-error/on-target-error
Paolo Bonzini [Thu, 18 Oct 2012 14:49:28 +0000 (16:49 +0200)]
mirror: add support for on-source-error/on-target-error

Error management is important for mirroring; otherwise, an error on the
target (even something as "innocent" as ENOSPC) requires to start again
with a full copy.  Similar to on_read_error/on_write_error, two separate
knobs are provided for on_source_error (reads) and on_target_error (writes).
The default is 'report' for both.

The 'ignore' policy will leave the sector dirty, so that it will be
retried later.  Thus, it will not cause corruption.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoiostatus: forward block_job_iostatus_reset to block job
Paolo Bonzini [Thu, 18 Oct 2012 14:49:27 +0000 (16:49 +0200)]
iostatus: forward block_job_iostatus_reset to block job

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add mirroring test case
Paolo Bonzini [Tue, 23 Oct 2012 14:39:22 +0000 (16:39 +0200)]
qemu-iotests: add mirroring test case

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agomirror: implement completion
Paolo Bonzini [Thu, 18 Oct 2012 14:49:25 +0000 (16:49 +0200)]
mirror: implement completion

Switching to the target of the migration is done mostly asynchronously,
and reported to management via the BLOCK_JOB_COMPLETED event; the only
synchronous phase is opening the backing files.  bdrv_open_backing_file
can always be done, even for migration of the full image (aka sync:
'full').  In this case, qmp_drive_mirror will create the target disk
with no backing file at all, and bdrv_open_backing_file will be a no-op.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqmp: add drive-mirror command
Paolo Bonzini [Thu, 18 Oct 2012 14:49:24 +0000 (16:49 +0200)]
qmp: add drive-mirror command

This adds the monitor commands that start the mirroring job.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agomirror: introduce mirror job
Paolo Bonzini [Thu, 18 Oct 2012 14:49:23 +0000 (16:49 +0200)]
mirror: introduce mirror job

This patch adds the implementation of a new job that mirrors a disk to
a new image while letting the guest continue using the old image.
The target is treated as a "black box" and data is copied from the
source to the target in the background.  This can be used for several
purposes, including storage migration, continuous replication, and
observation of the guest I/O in an external program.  It is also a
first step in replacing the inefficient block migration code that is
part of QEMU.

The job is possibly never-ending, but it is logically structured into
two phases: 1) copy all data as fast as possible until the target
first gets in sync with the source; 2) keep target in sync and
ensure that reopening to the target gets a correct (full) copy
of the source data.

The second phase is indicated by the progress in "info block-jobs"
reporting the current offset to be equal to the length of the file.
When the job is cancelled in the second phase, QEMU will run the
job until the source is clean and quiescent, then it will report
successful completion of the job.

In other words, the BLOCK_JOB_CANCELLED event means that the target
may _not_ be consistent with a past state of the source; the
BLOCK_JOB_COMPLETED event means that the target is consistent with
a past state of the source.  (Note that it could already happen
that management lost the race against QEMU and got a completion
event instead of cancellation).

It is not yet possible to complete the job and switch over to the target
disk.  The next patches will fix this and add many refinements to the
basic idea introduced here.  These include improved error management,
some tunable knobs and performance optimizations.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: introduce BLOCK_JOB_READY event
Paolo Bonzini [Mon, 23 Jul 2012 13:15:47 +0000 (15:15 +0200)]
block: introduce BLOCK_JOB_READY event

Even for jobs that need to be manually completed, management may want
to take care itself of the completion, not requiring the user to issue
a command to terminate the job.  In this case we want to avoid that
they poll us continuously, waiting for completion to become available.
Thus, add a new event that signals the phase switch and the availability
of the block-job-complete command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: add block-job-complete
Paolo Bonzini [Thu, 18 Oct 2012 14:49:21 +0000 (16:49 +0200)]
block: add block-job-complete

While streaming can be dropped as soon as it progressed through the whole
image, mirroring needs to be completed manually for two reasons: 1) so that
management knows exactly when the VM switches to the target; 2) because
for other use cases such as replication, we may leave the operation running
for the whole life of the virtual machine.

Add a new block job command that manually completes background operations.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: rename block_job_complete to block_job_completed
Paolo Bonzini [Thu, 18 Oct 2012 14:49:20 +0000 (16:49 +0200)]
block: rename block_job_complete to block_job_completed

The imperative will be used for the QMP command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: export dirty bitmap information in query-block
Paolo Bonzini [Wed, 1 Aug 2012 13:23:44 +0000 (15:23 +0200)]
block: export dirty bitmap information in query-block

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: introduce new dirty bitmap functionality
Paolo Bonzini [Thu, 18 Oct 2012 14:49:18 +0000 (16:49 +0200)]
block: introduce new dirty bitmap functionality

Assert that write_compressed is never used with the dirty bitmap.
Setting the bits early is wrong, because a coroutine might concurrently
examine them and copy incomplete data from the source.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: add bdrv_open_backing_file
Paolo Bonzini [Thu, 18 Oct 2012 14:49:17 +0000 (16:49 +0200)]
block: add bdrv_open_backing_file

Mirroring runs without the backing file so that it can be copied outside
QEMU.  However, we need to add it at the time the job is completed and
QEMU switches to the target.  Factor out the common bits of opening an
image and completing a mirroring operation.

The new function does not assume that the file is closed immediately after
it returns failure, so it keeps the BDRV_O_NO_BACKING flag up-to-date.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: add bdrv_query_stats
Paolo Bonzini [Thu, 18 Oct 2012 14:49:16 +0000 (16:49 +0200)]
block: add bdrv_query_stats

qmp_query_blockstat cannot have errors, remove the Error argument and
create a new public function bdrv_query_stats out of it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: add bdrv_query_info
Paolo Bonzini [Thu, 18 Oct 2012 14:49:15 +0000 (16:49 +0200)]
block: add bdrv_query_info

Extract it out of the implementation of "info block".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-config: Add new -add-fd command line option
Corey Bryant [Thu, 18 Oct 2012 19:19:34 +0000 (15:19 -0400)]
qemu-config: Add new -add-fd command line option

This option can be used for passing file descriptors on the
command line.  It mirrors the existing add-fd QMP command which
allows an fd to be passed to QEMU via SCM_RIGHTS and added to an
fd set.

This can be combined with commands such as -drive to link file
descriptors in an fd set to a drive:

    qemu-kvm -add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
             -add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
             -drive file=/dev/fdset/2,index=0,media=disk

This example adds dups of fds 3 and 4, and the accompanying opaque
strings to the fd set with ID=2.  qemu_open() already knows how
to handle a filename of this format.  qemu_open() searches the
corresponding fd set for an fd and when it finds a match, QEMU
goes on to use a dup of that fd just like it would have used an
fd that it opened itself.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>