OSDN Git Service

qmiga/qemu.git
11 years agoMerge remote-tracking branch 'stefanha/net' into staging
Anthony Liguori [Thu, 1 Nov 2012 16:13:59 +0000 (11:13 -0500)]
Merge remote-tracking branch 'stefanha/net' into staging

* stefanha/net:
  e1000: pre-initialize RAH/RAL registers
  net: Reject non-netdevs in qmp_netdev_del()
  net: use "socket" model name for UDP sockets
  e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'bonzini/threadpool' into staging
Anthony Liguori [Thu, 1 Nov 2012 16:13:39 +0000 (11:13 -0500)]
Merge remote-tracking branch 'bonzini/threadpool' into staging

* bonzini/threadpool: (39 commits)
  raw-win32: implement native asynchronous I/O
  raw-posix: move linux-aio.c to block/
  raw-win32: add emulated AIO support
  raw-posix: rename raw-posix-aio.h, hide unavailable prototypes
  raw: merge posix-aio-compat.c into block/raw-posix.c
  block: switch posix-aio-compat to threadpool
  threadpool: do not take lock in event_notifier_ready
  aio: add generic thread-pool facility
  qemu-thread: add QemuSemaphore
  linux-aio: use event notifiers
  aio: clean up now-unused functions
  main-loop: use aio_notify for qemu_notify_event
  main-loop: use GSource to poll AIO file descriptors
  aio: call aio_notify after setting I/O handlers
  aio: add aio_notify
  aio: make AioContexts GSources
  aio: add Win32 implementation
  aio: prepare for introducing GSource-based dispatch
  aio: add non-blocking variant of aio_wait
  aio: test node->deleted before calling io_flush
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Thu, 1 Nov 2012 16:12:50 +0000 (11:12 -0500)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

* qemu-kvm/uq/master: (28 commits)
  update-linux-headers.sh: Handle new kernel uapi/ directories
  target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID
  target-i386: cpu: make -cpu host/check/enforce code KVM-specific
  target-i386: make cpu_x86_fill_host() void
  Emulate qemu-kvms -no-kvm option
  Issue warning when deprecated -tdf option is used
  Issue warning when deprecated drive parameter boot=on|off is used
  Use global properties to emulate -no-kvm-pit-reinjection
  Issue warning when deprecated -no-kvm-pit is used
  Use machine options to emulate -no-kvm-irqchip
  cirrus_vga: allow configurable vram size
  target-i386: Add missing kvm cpuid feature name
  i386: cpu: add missing CPUID[EAX=7,ECX=0] flag names
  i386: kvm: filter CPUID leaf 7 based on GET_SUPPORTED_CPUID, too
  i386: kvm: reformat filter_features_for_kvm() code
  i386: kvm: filter CPUID feature words earlier, on cpu.c
  i386: kvm: mask cpuid_ext4_features bits earlier
  i386: kvm: mask cpuid_kvm_features earlier
  i386: kvm: x2apic is not supported without in-kernel irqchip
  i386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid()
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber/qom-cpu' into staging
Anthony Liguori [Thu, 1 Nov 2012 16:12:32 +0000 (11:12 -0500)]
Merge remote-tracking branch 'afaerber/qom-cpu' into staging

* afaerber/qom-cpu: (35 commits)
  target-i386: Pass X86CPU to kvm_handle_halt()
  target-i386: Pass X86CPU to kvm_get_mp_state()
  cpu: Move thread_id to CPUState
  cpus: Pass CPUState to run_on_cpu()
  target-i386: Pass X86CPU to cpu_x86_inject_mce()
  target-i386: Pass X86CPU to kvm_mce_inject()
  cpus: Pass CPUState to [qemu_]cpu_has_work()
  spapr: Pass PowerPCCPU to hypercalls
  spapr: Pass PowerPCCPU to spapr_hypercall()
  target-ppc: Pass PowerPCCPU to cpu_ppc_hypercall
  target-ppc: Pass PowerPCCPU to powerpc_excp()
  xtensa_pic: Pass XtensaCPU to xtensa_ccompare_cb()
  cpus: Pass CPUState to qemu_wait_io_event_common()
  cpus: Pass CPUState to flush_queued_work()
  cpu: Move queued_work_{first,last} to CPUState
  cpus: Pass CPUState to qemu_cpu_kick()
  target-ppc: Rename kvm_kick_{env => cpu} and pass PowerPCCPU
  ppc: Pass PowerPCCPU to {ppc6xx,ppc970,power7,ppc40x,ppce500}_set_irq()
  cpus: Pass CPUState to qemu_tcg_init_vcpu()
  cpus: Pass CPUState to qemu_tcg_cpu_thread_fn
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoarm_boot: Change initrd load address to "halfway through RAM"
Peter Maydell [Fri, 26 Oct 2012 15:29:38 +0000 (16:29 +0100)]
arm_boot: Change initrd load address to "halfway through RAM"

To avoid continually having to bump the initrd load address
to account for larger kernel images, put the initrd halfway
through RAM. This allows large kernels on new boards with lots
of RAM to work OK, without breaking existing usecases for
boards with only 32MB of RAM.

Note that this change fixes in passing a bug where we were
passing an overly large max_size to load_image_targphys()
for the initrd, which meant that we wouldn't correctly refuse
to load an enormous initrd that didn't actually fit into RAM.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Tested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoMerge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf
Aurelien Jarno [Thu, 1 Nov 2012 15:42:49 +0000 (16:42 +0100)]
Merge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf

* 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf:
  pseries: Cleanup duplications of ics_valid_irq() code
  pseries: Clean up inconsistent variable name in xics.c
  target-ppc: Extend FPU state for newer POWER CPUs
  target-ppc: Rework storage of VPA registration state
  Revert "PPC: pseries: Remove hack for PIO window"

11 years agoMerge branch 'arm-devs.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm
Aurelien Jarno [Thu, 1 Nov 2012 15:42:29 +0000 (16:42 +0100)]
Merge branch 'arm-devs.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm

* 'arm-devs.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm: (28 commits)
  hw/sd.c: add SD card save/load support
  vmstate: Add support for saving/loading bitmaps
  hw/sd.c: Fix erase for high capacity cards
  pflash_cfi01: Fix debug mode printfery
  pflash_cfi0x: QOMified
  pflash_cfi01: remove unused total_len field
  pflash_cfi0x: remove unused base field
  hw/versatile_i2c: Use LOG_GUEST_ERROR
  hw/arm_l2x0: Use LOG_GUEST_ERROR
  hw/arm_sysctl: Use LOG_GUEST_ERROR
  hw/armv7m_nvic: Use LOG_GUEST_ERROR and LOG_UNIMP
  hw/arm_timer: Use LOG_GUEST_ERROR and LOG_UNIMP
  hw/arm_gic: Use LOG_GUEST_ERROR
  hw/arm11mpcore: Use LOG_GUEST_ERROR rather than hw_error()
  hw/pl190: Use LOG_UNIMP rather than hw_error()
  hw/pl110: Use LOG_GUEST_ERROR rather than hw_error()
  hw/pl080: Use LOG_GUEST_ERROR and LOG_UNIMP
  hw/pl061: Use LOG_GUEST_ERROR
  hw/pl050: Use LOG_GUEST_ERROR
  hw/exynos4_boards: Don't prematurely explode QEMUMachineInitArgs
  ...

11 years agopseries: Cleanup duplications of ics_valid_irq() code
David Gibson [Mon, 29 Oct 2012 17:25:02 +0000 (17:25 +0000)]
pseries: Cleanup duplications of ics_valid_irq() code

A couple of places in xics.c open-coded the same logic as is already
implemented in ics_valid_irq().  This patch fixes the code duplication.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agopseries: Clean up inconsistent variable name in xics.c
David Gibson [Mon, 29 Oct 2012 17:25:00 +0000 (17:25 +0000)]
pseries: Clean up inconsistent variable name in xics.c

Throughout xics.c 'nr' is used to refer to a global interrupt number, and
'server' is used to refer to an interrupt server number (i.e. CPU number).
Except in icp_set_mfrr(), where 'nr' is used as a server number.  Fix this
confusing inconsistency.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Extend FPU state for newer POWER CPUs
David Gibson [Mon, 29 Oct 2012 17:24:59 +0000 (17:24 +0000)]
target-ppc: Extend FPU state for newer POWER CPUs

This patch adds some extra FPU state to CPUPPCState.  Specifically,
fpscr is extended to a target_ulong bits, since some recent (64 bit)
CPUs now have more status bits than fit inside 32 bits.  Also, we add
the 32 VSR registers present on CPUs with VSX (these extend the
standard FP regs, which together with the Altivec/VMX registers form a
64 x 128bit register file for VSX).

We don't actually support the instructions using these extra registers
in TCG yet, but we still need a place to store the state so we can
sync it with KVM and savevm/loadvm it.  This patch updates the savevm
code to not fail on the extended state, but also does not actually
save it - that's a project for another patch.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Rework storage of VPA registration state
David Gibson [Mon, 29 Oct 2012 17:24:58 +0000 (17:24 +0000)]
target-ppc: Rework storage of VPA registration state

We change the storage of the VPA information to explicitly use fixed
size integer types which will make life easier for syncing this data with
KVM, which we will need in future.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: fix commit message]
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agoRevert "PPC: pseries: Remove hack for PIO window"
David Gibson [Mon, 29 Oct 2012 17:24:57 +0000 (17:24 +0000)]
Revert "PPC: pseries: Remove hack for PIO window"

This reverts commit a178274efabcbbc5d44805b51def874e47051325.

Contrary to that commit's message, the users of old_portio are not all
gone.  In particular VGA still uses it via portio_list_add().

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agoe1000: pre-initialize RAH/RAL registers
Gabriel L. Somlo [Wed, 31 Oct 2012 18:15:39 +0000 (14:15 -0400)]
e1000: pre-initialize RAH/RAL registers

Some guest operating systems' drivers (Mac OS X in particular) fail to
properly initialize the Receive Address registers (probably expecting
them to be pre-initialized by an earlier component, such as a specific
proprietary BIOS). This patch pre-initializes the RA registers, allowing
OS X networking to function properly. Other guest operating systems are
not affected, and free to (re)initialize these registers during boot.

[According to the datasheet the Address Valid bits in the RA registers
are cleared on PCI or software reset.  This patch adds the NIC's MAC
address and sets Address Valid on reset.  So we diverge from real
hardware behavior here. -- Stefan]

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agonet: Reject non-netdevs in qmp_netdev_del()
Stefan Hajnoczi [Wed, 24 Oct 2012 12:34:12 +0000 (14:34 +0200)]
net: Reject non-netdevs in qmp_netdev_del()

The netdev_del command crashes when given a -net device, because it
calls qemu_opts_del(NULL).

Check that this is a -netdev before attempting to delete it and the
QemuOpts.

Note the subtle change from qemu_find_opts_err("netdev", errp) to
qemu_find_opts_err("netdev", NULL).  Since "netdev" is a built in
options group and we don't check for NULL return anyway, there's no use
in passing errp here.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agonet: use "socket" model name for UDP sockets
Lei Li [Thu, 1 Nov 2012 09:39:55 +0000 (17:39 +0800)]
net: use "socket" model name for UDP sockets

Fix the problem that can not delete the udp socket.
It's caused by passing "udp" model to net_socket_udp_init,
but we do not have "udp" model in our model list.
Pass the right model "socket" to init function.

https://bugs.launchpad.net/qemu/+bug/1073585?comments=all

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoe1000: drop check_rxov, always treat RX ring with RDH == RDT as empty
Dmitry Fleytman [Fri, 19 Oct 2012 05:56:55 +0000 (07:56 +0200)]
e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty

Real HW always treats RX ring with RDH == RDT as empty.
Emulation is supposed to behave the same.

Reported-by: Chris Webb <chris.webb@elastichosts.com>
Reported-by: Richard Davies <richard.davies@elastichosts.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agotarget-mips: don't flush extra TLB on permissions upgrade
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: don't flush extra TLB on permissions upgrade

If the guest uses a TLBWI instruction for upgrading permissions, we
don't need to flush the extra TLBs. This improve boot time performance
by about 10%.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: fix TLBR wrt SEGMask
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: fix TLBR wrt SEGMask

Like r4k_map_address(), r4k_helper_tlbp() should use SEGMask to mask the
address.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: use deposit instead of hardcoded version
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: use deposit instead of hardcoded version

Use the deposit op instead of and hardcoded bit field insertion. It
allows the host to emit the corresponding instruction if available.

At the same time remove the (lsb > msb) test. The MIPS64R2 instruction
set manual says "Because of the instruction format, lsb can never be
greater than msb, so there is no UNPREDICATABLE case for this
instruction."

(Bug reported as LP:1071149.)
Cc: Никита Канунников <n.kanunnikov@sbtcom.ru>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: optimize ddiv/ddivu/div/divu with movcond
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: optimize ddiv/ddivu/div/divu with movcond

The result of a division by 0, or a division of INT_MIN by -1 in the
signed case, is unpredictable. Just replace 0 by 1 in that case so that
it doesn't trigger a floating point exception on the host.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: implement movn/movz using movcond
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: implement movn/movz using movcond

Avoid the branches in movn/movz implementation and replace them with
movcond. Also update a wrong command.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: don't use local temps for store conditional
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: don't use local temps for store conditional

Store conditional operations only need local temps in user mode. Fix
the code to use temp local only in user mode, this spares two memory
stores in system mode.

At the same time remove a wrong a wrong copied & pasted comment,
store operations don't have a register destination.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: implement unaligned loads using TCG
Aurelien Jarno [Tue, 9 Oct 2012 19:53:21 +0000 (21:53 +0200)]
target-mips: implement unaligned loads using TCG

Load/store from helpers should be avoided as they are quite
inefficient. Rewrite unaligned loads instructions using TCG and
aligned loads. The number of actual loads operations to implement
an unaligned load instruction is reduced from up to 8 to 1.

Note: As we can't rely on shift by 32 or 64 undefined behaviour,
the code loads already shift by one constants.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: simplify load/store microMIPS helpers
Aurelien Jarno [Tue, 9 Oct 2012 19:53:20 +0000 (21:53 +0200)]
target-mips: simplify load/store microMIPS helpers

load/store microMIPS helpers are reinventing the wheel. Call do_lw,
do_ll, do_sw and do_sl instead of using a macro calling the cpu_*
load/store functions.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: optimize load operations
Aurelien Jarno [Tue, 9 Oct 2012 19:53:20 +0000 (21:53 +0200)]
target-mips: optimize load operations

Only allocate t1 when needed.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: cleanup load/store operations
Aurelien Jarno [Tue, 9 Oct 2012 19:53:20 +0000 (21:53 +0200)]
target-mips: cleanup load/store operations

Load/store operations use macros for historical reasons. Now that there
is no point in keeping them, replace them by direct calls to qemu_ld/st.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: restore CPU state after an FPU exception
Aurelien Jarno [Sun, 28 Oct 2012 18:34:03 +0000 (19:34 +0100)]
target-mips: restore CPU state after an FPU exception

Rework *raise_exception*() functions so that they can be called from
other helpers, passing the return address as an argument.

Use do_raise_exception() function in update_fcr31() to correctly restore
the CPU state after an FPU exception.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: use softfloat constants when possible
Aurelien Jarno [Tue, 23 Oct 2012 08:12:00 +0000 (10:12 +0200)]
target-mips: use softfloat constants when possible

softfloat already has a few constants defined, use them instead of
redefining them in target-mips.

Rename FLOAT_SNAN32 and FLOAT_SNAN64 to FP_TO_INT32_OVERFLOW and
FP_TO_INT64_OVERFLOW as even if they have the same value, they are
technically different (and defined differently in the MIPS ISA).

Remove the unused constants.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: cleanup float to int conversion helpers
Aurelien Jarno [Tue, 23 Oct 2012 07:53:50 +0000 (09:53 +0200)]
target-mips: cleanup float to int conversion helpers

Instead of accessing the flags from the floating point control
register after updating it, read the softfloat flags.

This is just code cleanup and should not change the behaviour.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: fix FPU exceptions
Aurelien Jarno [Tue, 9 Oct 2012 19:53:20 +0000 (21:53 +0200)]
target-mips: fix FPU exceptions

For each FPU instruction that can trigger an FPU exception, to call
call update_fcr31() after.

Remove the manual NaN assignment in case of float to float operation, as
softfloat is already taking care of that. However for float to int
operation, the value has to be changed to the MIPS one. In the cvtpw_ps
case, the two registers have to be handled separately to guarantee
a correct final value in both registers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: keep softfloat exception set to 0 between instructions
Aurelien Jarno [Sun, 28 Oct 2012 17:08:27 +0000 (18:08 +0100)]
target-mips: keep softfloat exception set to 0 between instructions

Instead of clearing the softfloat exception flags before each floating
point instruction, reset them to 0 in update_fcr31() when an exception
is detected.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: use the softfloat floatXX_muladd functions
Aurelien Jarno [Tue, 9 Oct 2012 19:53:20 +0000 (21:53 +0200)]
target-mips: use the softfloat floatXX_muladd functions

Use the new softfloat floatXX_muladd() functions to implement the madd,
msub, nmadd and nmsub instructions. At the same time replace the name of
the helpers by the name of the instruction, as the only reason for the
previous names was to keep the macros simple.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agosoftfloat: implement fused multiply-add NaN propagation for MIPS
Aurelien Jarno [Tue, 9 Oct 2012 19:53:20 +0000 (21:53 +0200)]
softfloat: implement fused multiply-add NaN propagation for MIPS

Add a pickNaNMulAdd function for MIPS, implementing NaN propagation
rules for MIPS fused multiply-add instructions.

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-mips: do not save CPU state when using retranslation
Aurelien Jarno [Sun, 28 Oct 2012 14:55:47 +0000 (15:55 +0100)]
target-mips: do not save CPU state when using retranslation

When the CPU state after a possible retranslation is going to be handled
through code retranslation, we don't need to save the CPU state before.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: correctly restore btarget upon exception
Aurelien Jarno [Sun, 28 Oct 2012 14:42:55 +0000 (15:42 +0100)]
target-mips: correctly restore btarget upon exception

When the CPU state is restored through retranslation after an exception,
btarget should also be restored.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotcg: don't remove op if output needs to be synced to memory
Aurelien Jarno [Tue, 30 Oct 2012 23:50:15 +0000 (00:50 +0100)]
tcg: don't remove op if output needs to be synced to memory

Commit 9c43b68de628a1e2cba556adfb71c17028eb802e do not correctly check
for dead outputs when they need to be synced to memory in case of
half-dead operations.

Fix that by applying the same pattern than for the default case.

Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-alpha: Use TCG_CALL_NO_WG
Richard Henderson [Tue, 30 Oct 2012 23:30:55 +0000 (10:30 +1100)]
target-alpha: Use TCG_CALL_NO_WG

Mark helper functions that raise exceptions, but otherwise do not
change TCG register state, with TCG_CALL_NO_WG.

Signed-off-by: Richard Henderson <rth@twiddle.net>
11 years agochardev: Use timer instead of bottom-half to postpone open event
Jan Kiszka [Fri, 12 Oct 2012 07:52:49 +0000 (09:52 +0200)]
chardev: Use timer instead of bottom-half to postpone open event

As the block layer may decide to flush bottom-halfs while the machine is
still initializing (e.g. to read geometry data from the disk), our
postponed open event may be processed before the last frontend
registered with a muxed chardev.

Until the semantics of BHs have been clarified, use an expired timer to
achieve the same effect (suggested by Paolo Bonzini). This requires to
perform the alarm timer initialization earlier as otherwise timer
subsystem can be used before being ready.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11 years agotarget-mips: remove #if defined(TARGET_MIPS64) in opcode enums
Aurelien Jarno [Wed, 31 Oct 2012 21:14:46 +0000 (22:14 +0100)]
target-mips: remove #if defined(TARGET_MIPS64) in opcode enums

All switch() decoding instruction have a default entry, so it is possible
to have unused enum entries. Remove conditional definitions of MIPS64
opcode enums, as it only makes the code less readable.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Change TODO file
Jia Liu [Wed, 24 Oct 2012 14:17:14 +0000 (22:17 +0800)]
target-mips: Change TODO file

Change DSP r1 & DSP r2 into microMIPS DSP encodings in TODO file.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP testcases
Jia Liu [Wed, 24 Oct 2012 14:17:13 +0000 (22:17 +0800)]
target-mips: Add ASE DSP testcases

Add MIPS ASE DSP testcases.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP processors
Jia Liu [Wed, 24 Oct 2012 14:17:12 +0000 (22:17 +0800)]
target-mips: Add ASE DSP processors

Add 74kf and mips64dspr2-generic-cpu model for test.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP accumulator instructions
Jia Liu [Wed, 24 Oct 2012 14:17:11 +0000 (22:17 +0800)]
target-mips: Add ASE DSP accumulator instructions

Add MIPS ASE DSP Accumulator and DSPControl Access instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP compare-pick instructions
Jia Liu [Wed, 24 Oct 2012 14:17:10 +0000 (22:17 +0800)]
target-mips: Add ASE DSP compare-pick instructions

Add MIPS ASE DSP Compare-Pick instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP bit/manipulation instructions
Jia Liu [Wed, 24 Oct 2012 14:17:09 +0000 (22:17 +0800)]
target-mips: Add ASE DSP bit/manipulation instructions

Add MIPS ASE DSP Bit/Manipulation instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP multiply instructions
Jia Liu [Wed, 24 Oct 2012 14:17:08 +0000 (22:17 +0800)]
target-mips: Add ASE DSP multiply instructions

Add MIPS ASE DSP Multiply instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP GPR-based shift instructions
Jia Liu [Wed, 24 Oct 2012 14:17:07 +0000 (22:17 +0800)]
target-mips: Add ASE DSP GPR-based shift instructions

Add MIPS ASE DSP GPR-Based Shift instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP arithmetic instructions
Jia Liu [Wed, 24 Oct 2012 14:17:06 +0000 (22:17 +0800)]
target-mips: Add ASE DSP arithmetic instructions

Add MIPS ASE DSP Arithmetic instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP load instructions
Jia Liu [Wed, 24 Oct 2012 14:17:05 +0000 (22:17 +0800)]
target-mips: Add ASE DSP load instructions

Add MIPS ASE DSP Load instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP branch instructions
Jia Liu [Wed, 24 Oct 2012 14:17:04 +0000 (22:17 +0800)]
target-mips: Add ASE DSP branch instructions

Add MIPS ASE DSP Branch instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoUse correct acc value to index cpu_HI/cpu_LO rather than using a fix number
Jia Liu [Wed, 24 Oct 2012 14:17:03 +0000 (22:17 +0800)]
Use correct acc value to index cpu_HI/cpu_LO rather than using a fix number

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP resources access check
Jia Liu [Wed, 24 Oct 2012 14:17:02 +0000 (22:17 +0800)]
target-mips: Add ASE DSP resources access check

Add MIPS ASE DSP resources access check.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Add ASE DSP internal functions
Jia Liu [Wed, 24 Oct 2012 14:17:01 +0000 (22:17 +0800)]
target-mips: Add ASE DSP internal functions

Add internal functions using by MIPS ASE DSP instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoMerge remote-tracking branch 'origin/master' into threadpool
Paolo Bonzini [Wed, 31 Oct 2012 09:42:51 +0000 (10:42 +0100)]
Merge remote-tracking branch 'origin/master' into threadpool

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoraw-win32: implement native asynchronous I/O
Paolo Bonzini [Fri, 26 Oct 2012 09:43:58 +0000 (11:43 +0200)]
raw-win32: implement native asynchronous I/O

With the new support for EventNotifiers in the AIO event loop, we
can hook a completion port to every opened file and use asynchronous
I/O on them.

Wine's support is extremely inefficient, also because it really does
the I/O synchronously on regular files. (!)  But it works, and it is
good to keep the Win32 and POSIX ports as similar as possible.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoraw-posix: move linux-aio.c to block/
Paolo Bonzini [Fri, 26 Oct 2012 09:27:45 +0000 (11:27 +0200)]
raw-posix: move linux-aio.c to block/

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoraw-win32: add emulated AIO support
Paolo Bonzini [Sat, 9 Jun 2012 02:48:28 +0000 (04:48 +0200)]
raw-win32: add emulated AIO support

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoraw-posix: rename raw-posix-aio.h, hide unavailable prototypes
Paolo Bonzini [Sat, 9 Jun 2012 08:57:37 +0000 (10:57 +0200)]
raw-posix: rename raw-posix-aio.h, hide unavailable prototypes

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoraw: merge posix-aio-compat.c into block/raw-posix.c
Paolo Bonzini [Fri, 25 May 2012 09:46:27 +0000 (11:46 +0200)]
raw: merge posix-aio-compat.c into block/raw-posix.c

Making the qemu_paiocb specific to raw devices will let us access members
of the BDRVRawState arbitrarily.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoblock: switch posix-aio-compat to threadpool
Paolo Bonzini [Thu, 24 May 2012 16:03:13 +0000 (18:03 +0200)]
block: switch posix-aio-compat to threadpool

This is not meant for portability, but to remove code duplication.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agothreadpool: do not take lock in event_notifier_ready
Paolo Bonzini [Wed, 31 Oct 2012 09:09:11 +0000 (10:09 +0100)]
threadpool: do not take lock in event_notifier_ready

The ordering is:

    worker thread                         consumer thread
    -------------------------------------------------------------------
    write ret                             event_notifier_test_and_clear
    wmb()                                 read state
    write state                           rmb()
    event_notifier_set                    read ret

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoaio: add generic thread-pool facility
Paolo Bonzini [Thu, 23 Feb 2012 12:23:34 +0000 (13:23 +0100)]
aio: add generic thread-pool facility

Add a generic thread-pool.  The code is roughly based on posix-aio-compat.c,
with some changes, especially the following:

- use QemuSemaphore instead of QemuCond;

- separate the state of the thread from the return code of the worker
function.  The return code is totally opaque for the thread pool;

- do not busy wait when doing cancellation.

A more generic threadpool (but still specific to I/O so that in the future
it can use special scheduling classes or PI mutexes) can have many uses:
it allows more flexibility in raw-posix.c and can more easily be extended
to Win32, and it will also be used to do an msync of the persistent bitmap.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoqemu-thread: add QemuSemaphore
Paolo Bonzini [Mon, 8 Aug 2011 12:36:41 +0000 (14:36 +0200)]
qemu-thread: add QemuSemaphore

The new thread pool will use semaphores instead of condition
variables, because QemuCond does not have qemu_cond_timedwait.
(I also like it more this way).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agotarget-i386: Pass X86CPU to kvm_handle_halt()
Andreas Färber [Thu, 3 May 2012 15:00:31 +0000 (17:00 +0200)]
target-i386: Pass X86CPU to kvm_handle_halt()

Needed for moving interrupt_request and halted fields to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Pass X86CPU to kvm_get_mp_state()
Andreas Färber [Thu, 3 May 2012 14:56:46 +0000 (16:56 +0200)]
target-i386: Pass X86CPU to kvm_get_mp_state()

Needed for moving halted field to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Move thread_id to CPUState
Andreas Färber [Thu, 3 May 2012 04:59:07 +0000 (06:59 +0200)]
cpu: Move thread_id to CPUState

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpus: Pass CPUState to run_on_cpu()
Andreas Färber [Thu, 3 May 2012 12:58:47 +0000 (14:58 +0200)]
cpus: Pass CPUState to run_on_cpu()

CPUArchState is no longer needed.

Move the declaration to include/qemu/cpu.h and add documentation.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Pass X86CPU to cpu_x86_inject_mce()
Andreas Färber [Thu, 3 May 2012 13:22:54 +0000 (15:22 +0200)]
target-i386: Pass X86CPU to cpu_x86_inject_mce()

Needed for changing run_on_cpu() argument to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Pass X86CPU to kvm_mce_inject()
Andreas Färber [Thu, 3 May 2012 13:13:58 +0000 (15:13 +0200)]
target-i386: Pass X86CPU to kvm_mce_inject()

Needed for changing cpu_x86_inject_mce() argument to X86CPU.

Signed-off-by: Andreas Färber <afaerber@suse.de>
[AF: Rebased onto hwaddr]

11 years agocpus: Pass CPUState to [qemu_]cpu_has_work()
Andreas Färber [Thu, 3 May 2012 04:43:49 +0000 (06:43 +0200)]
cpus: Pass CPUState to [qemu_]cpu_has_work()

For target-mips also change the return type to bool.

Make include paths for cpu-qom.h consistent for alpha and unicore32.

Signed-off-by: Andreas Färber <afaerber@suse.de>
[AF: Updated new target-openrisc function accordingly]
Acked-by: Richard Henderson <rth@twiddle.net> (for alpha)
11 years agoupdate-linux-headers.sh: Handle new kernel uapi/ directories
Peter Maydell [Mon, 22 Oct 2012 11:54:39 +0000 (12:54 +0100)]
update-linux-headers.sh: Handle new kernel uapi/ directories

Recent kernels have moved to keeping the userspace headers
in uapi/ subdirectories. This breaks the detection of whether an
architecture has KVM support in the kernel because kvm.h has
moved in the kernel source tree. Update the check to support
both the old and new locations.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agotarget-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID
Eduardo Habkost [Wed, 24 Oct 2012 21:44:07 +0000 (19:44 -0200)]
target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID

Change the kvm_cpu_fill_host() function to use
kvm_arch_get_supported_cpuid() instead of running the CPUID instruction
directly, when checking for supported CPUID features.

This should solve two problems at the same time:

 * "-cpu host" was not enabling features that don't need support on
   the host CPU (e.g. x2apic);
 * "check" and "enforce" options were not detecting problems when the
   host CPU did support a feature, but the KVM kernel code didn't
   support it.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agotarget-i386: cpu: make -cpu host/check/enforce code KVM-specific
Eduardo Habkost [Wed, 24 Oct 2012 21:44:06 +0000 (19:44 -0200)]
target-i386: cpu: make -cpu host/check/enforce code KVM-specific

Rationale:
 * "-cpu host" is available only when using KVM
 * The current implementation of -cpu check/enforce
   (check_features_against_host()) makes sense only when using KVM.

So this makes the functions check_features_against_host() and
cpu_x86_fill_host() KVM-specific, document them as such, and rename them
to kvm_check_features_against_host() and kvm_cpu_fill_host().

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agotarget-i386: make cpu_x86_fill_host() void
Eduardo Habkost [Wed, 24 Oct 2012 21:44:05 +0000 (19:44 -0200)]
target-i386: make cpu_x86_fill_host() void

The return value of that function is always 0, and is always ignored.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoEmulate qemu-kvms -no-kvm option
Jan Kiszka [Fri, 5 Oct 2012 17:51:45 +0000 (14:51 -0300)]
Emulate qemu-kvms -no-kvm option

Releases of qemu-kvm will be interrupted at qemu 1.3.0.
Users should switch to plain qemu releases.
To avoid breaking scenarios which are setup with command line
options specific to qemu-kvm, port these switches from qemu-kvm
to qemu.git.

Port -no-kvm option.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoIssue warning when deprecated -tdf option is used
Jan Kiszka [Fri, 5 Oct 2012 17:51:44 +0000 (14:51 -0300)]
Issue warning when deprecated -tdf option is used

Releases of qemu-kvm will be interrupted at qemu 1.3.0.
Users should switch to plain qemu releases.
To avoid breaking scenarios which are setup with command line
options specific to qemu-kvm, port these switches from qemu-kvm
to qemu.git.

Port -tdf option.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoIssue warning when deprecated drive parameter boot=on|off is used
Jan Kiszka [Fri, 5 Oct 2012 17:51:43 +0000 (14:51 -0300)]
Issue warning when deprecated drive parameter boot=on|off is used

Releases of qemu-kvm will be interrupted at qemu 1.3.0.
Users should switch to plain qemu releases.
To avoid breaking scenarios which are setup with command line
options specific to qemu-kvm, port these switches from qemu-kvm
to qemu.git.

Port drive boot option. From the qemu-kvm original commit message:

We do not want to maintain this option forever. It will be removed after
a grace period of a few releases. So warn the user that this option has
no effect and will become invalid soon.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoUse global properties to emulate -no-kvm-pit-reinjection
Jan Kiszka [Fri, 5 Oct 2012 17:51:42 +0000 (14:51 -0300)]
Use global properties to emulate -no-kvm-pit-reinjection

Releases of qemu-kvm will be interrupted at qemu 1.3.0.
Users should switch to plain qemu releases.
To avoid breaking scenarios which are setup with command line
options specific to qemu-kvm, port these switches from qemu-kvm
to qemu.git.

Port -no-kvm-pit-reinjection.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoIssue warning when deprecated -no-kvm-pit is used
Jan Kiszka [Fri, 5 Oct 2012 17:51:41 +0000 (14:51 -0300)]
Issue warning when deprecated -no-kvm-pit is used

Releases of qemu-kvm will be interrupted at qemu 1.3.0.
Users should switch to plain qemu releases.
To avoid breaking scenarios which are setup with command line
options specific to qemu-kvm, port these switches from qemu-kvm
to qemu.git.

Port -no-kvm-pit option.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoUse machine options to emulate -no-kvm-irqchip
Jan Kiszka [Fri, 5 Oct 2012 17:51:40 +0000 (14:51 -0300)]
Use machine options to emulate -no-kvm-irqchip

Releases of qemu-kvm will be interrupted at qemu 1.3.0.
Users should switch to plain qemu releases.
To avoid breaking scenarios which are setup with command line
options specific to qemu-kvm, port these switches from qemu-kvm
to qemu.git.

Port -no-kvm-irqchip option.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agocirrus_vga: allow configurable vram size
Marcelo Tosatti [Fri, 5 Oct 2012 17:51:39 +0000 (14:51 -0300)]
cirrus_vga: allow configurable vram size

Allow RAM size to be configurable for cirrus, to allow migration
compatibility from qemu-kvm.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agotarget-i386: Add missing kvm cpuid feature name
Don Slutz [Fri, 12 Oct 2012 19:43:23 +0000 (15:43 -0400)]
target-i386: Add missing kvm cpuid feature name

Currently "-cpu host,-kvmclock,-kvm_nopiodelay,-kvm_mmu" does not
turn off all bits in CPUID 0x40000001 EAX.

The missing ones is KVM_FEATURE_STEAL_TIME.

This adds the name kvm_steal_time.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: cpu: add missing CPUID[EAX=7,ECX=0] flag names
Eduardo Habkost [Tue, 9 Oct 2012 14:03:59 +0000 (11:03 -0300)]
i386: cpu: add missing CPUID[EAX=7,ECX=0] flag names

This makes QEMU recognize the following CPU flag names:

 Flags            | Corresponding KVM kernel commit
 -----------------+----------------------------------------
 FSGSBASE         | 176f61da82435eae09cc96f70b530d1ba0746b8b
 AVX2, BMI1, BMI2 | fb215366b3c7320ac25dca766a0152df16534932
 HLE, RTM         | 83c529151ab0d4a813e3f6a3e293fff75d468519
 INVPCID          | ad756a1603c5fac207758faaac7f01c34c9d0b7b
 ERMS             | a01c8f9b4e266df1d7166d23216f2060648f862d

Reviewed-by: Don Slutz <Don@CloudSwitch.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: filter CPUID leaf 7 based on GET_SUPPORTED_CPUID, too
Eduardo Habkost [Thu, 4 Oct 2012 20:49:07 +0000 (17:49 -0300)]
i386: kvm: filter CPUID leaf 7 based on GET_SUPPORTED_CPUID, too

Now that CPUID leaf 7 features can be enabled/disabled on the
command-line, we need to filter them properly using GET_SUPPORTED_CPUID,
at the same place where other features are filtered out.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: reformat filter_features_for_kvm() code
Eduardo Habkost [Thu, 4 Oct 2012 20:49:06 +0000 (17:49 -0300)]
i386: kvm: reformat filter_features_for_kvm() code

Cosmetic, but it will also help to make futher patches easier to review.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: filter CPUID feature words earlier, on cpu.c
Eduardo Habkost [Thu, 4 Oct 2012 20:49:05 +0000 (17:49 -0300)]
i386: kvm: filter CPUID feature words earlier, on cpu.c

cpu.c contains the code that will check if all requested CPU features
are available, so the filtering of KVM features must be there, so we can
implement "check" and "enforce" properly.

The only point where kvm_arch_init_vcpu() is called on i386 is:

- cpu_x86_init()
  - x86_cpu_realize() (after cpu_x86_register() is called)
    - qemu_init_vcpu()
      - qemu_kvm_start_vcpu()
        - qemu_kvm_thread_fn() (on a new thread)
          - kvm_init_vcpu()
            - kvm_arch_init_vcpu()

With this patch, the filtering will be done earlier, at:
- cpu_x86_init()
  - cpu_x86_register() (before x86_cpu_realize() is called)

Also, the KVM CPUID filtering will now be done at the same place where
the TCG CPUID feature filtering is done. Later, the code can be changed
to use the same filtering code for the "check" and "enforce" modes, as
now the cpu.c code knows exactly which CPU features are going to be
exposed to the guest (and much earlier).

One thing I was worrying about when doing this is that
kvm_arch_get_supported_cpuid() depends on kvm_irqchip_in_kernel(), and
maybe the 'kvm_kernel_irqchip' global variable wasn't initialized yet at
CPU creation time. But kvm_kernel_irqchip is initialized during
kvm_init(), that is called very early (much earlier than the machine
init function), and kvm_init() is already a requirement to run the
GET_SUPPORTED_CPUID ioctl() (as kvm_init() initializes the kvm_state
global variable).

Side note: it would be nice to keep KVM-specific code inside kvm.c. The
problem is that properly implementing -cpu check/enforce code (that's
inside cpu.c) depends directly on the feature bit filtering done using
kvm_arch_get_supported_cpuid(). Currently -cpu check/enforce is broken
because it simply uses the host CPU feature bits instead of
GET_SUPPORTED_CPUID, and we need to fix that.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: mask cpuid_ext4_features bits earlier
Eduardo Habkost [Thu, 4 Oct 2012 20:49:04 +0000 (17:49 -0300)]
i386: kvm: mask cpuid_ext4_features bits earlier

This way all the filtering by GET_SUPPORTED_CPUID is being done at the
same place in the code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: mask cpuid_kvm_features earlier
Eduardo Habkost [Thu, 4 Oct 2012 20:49:03 +0000 (17:49 -0300)]
i386: kvm: mask cpuid_kvm_features earlier

Instead of masking the KVM feature bits very late (while building the
KVM_SET_CPUID2 data), mask it out on env->cpuid_kvm_features, at the
same point where the other feature words are masked out.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: x2apic is not supported without in-kernel irqchip
Eduardo Habkost [Thu, 4 Oct 2012 20:49:02 +0000 (17:49 -0300)]
i386: kvm: x2apic is not supported without in-kernel irqchip

This is necessary so that x2apic is not improperly enabled when the
in-kernel irqchip is disabled.

This won't generate a warning with "-cpu ...,check" because the current
check/enforce code is broken (it checks the host CPU data directly,
instead of using kvm_arch_get_supported_cpuid()), but it will be
eventually fixed to properly report the missing x2apic flag.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid()
Eduardo Habkost [Thu, 4 Oct 2012 20:49:01 +0000 (17:49 -0300)]
i386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid()

This moves the CPUID_EXT_TSC_DEADLINE_TIMER CPUID flag hacking from
kvm_arch_init_vcpu() to kvm_arch_get_supported_cpuid().

Full git grep for kvm_arch_get_supported_cpuid:

   kvm.h:uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
   target-i386/cpu.c:        x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
   target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
   target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);
   target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);
   target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);
   target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX);
   target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX);
   target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX);
   target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX);
   target-i386/kvm.c:uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
   target-i386/kvm.c:        cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
   target-i386/kvm.c:    env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
 * target-i386/kvm.c:    env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX);
   target-i386/kvm.c:    env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
   target-i386/kvm.c:    env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
   target-i386/kvm.c:    env->cpuid_svm_features  &= kvm_arch_get_supported_cpuid(s, 0x8000000A,
   target-i386/kvm.c:        kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
   target-i386/kvm.c:            kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);

Note that there is only one call for CPUID[1].ECX above (*), and it is
the one that gets hacked to include CPUID_EXT_TSC_DEADLINE_TIMER, so we
can simply make kvm_arch_get_supported_cpuid() set it, to let the rest
of the code know the flag can be safely set by QEMU.

One thing I was worrying about when doing this is that now
kvm_arch_get_supported_cpuid() depends on kvm_irqchip_in_kernel(). But
the 'kvm_kernel_irqchip' global variable is initialized during
kvm_init(), that is called very early, and kvm_init() is already a
requirement to run the GET_SUPPORTED_CPUID ioctl() (as kvm_init() is the
function that initializes the 'kvm_state' global variable).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: set CPUID_EXT_HYPERVISOR on kvm_arch_get_supported_cpuid()
Eduardo Habkost [Thu, 4 Oct 2012 20:49:00 +0000 (17:49 -0300)]
i386: kvm: set CPUID_EXT_HYPERVISOR on kvm_arch_get_supported_cpuid()

Full grep for kvm_arch_get_supported_cpuid:

   kvm.h:uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
   target-i386/cpu.c:        x86_cpu_def->cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
   target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
   target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);
   target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);
   target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);
   target-i386/cpu.c:            *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX);
   target-i386/cpu.c:            *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX);
   target-i386/cpu.c:            *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX);
   target-i386/cpu.c:            *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX);
   target-i386/kvm.c:uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
   target-i386/kvm.c:        cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
   target-i386/kvm.c:    env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
 * target-i386/kvm.c:    env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX);
   target-i386/kvm.c:    env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
   target-i386/kvm.c:    env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
   target-i386/kvm.c:    env->cpuid_svm_features  &= kvm_arch_get_supported_cpuid(s, 0x8000000A,
   target-i386/kvm.c:        kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
   target-i386/kvm.c:            kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);

Note that there is only one call for CPUID[1].ECX above (*), and it is
the one that gets hacked to include CPUID_EXT_HYPERVISOR, so we can
simply make kvm_arch_get_supported_cpuid() set it, to let the rest of
the code automatically know that the flag can be safely set by QEMU.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: kvm_arch_get_supported_cpuid: replace if+switch with single 'if'
Eduardo Habkost [Thu, 4 Oct 2012 20:48:59 +0000 (17:48 -0300)]
i386: kvm: kvm_arch_get_supported_cpuid: replace if+switch with single 'if'

Additional fixups will be added, and making them a single 'if/else if'
chain makes it clearer than two nested switch statements.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: extract try_get_cpuid() loop to get_supported_cpuid() function
Eduardo Habkost [Thu, 4 Oct 2012 20:48:58 +0000 (17:48 -0300)]
i386: kvm: extract try_get_cpuid() loop to get_supported_cpuid() function

No behavior change, just code movement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: extract CPUID entry lookup to cpuid_find_entry() function
Eduardo Habkost [Thu, 4 Oct 2012 20:48:57 +0000 (17:48 -0300)]
i386: kvm: extract CPUID entry lookup to cpuid_find_entry() function

No behavior change, just code movement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: extract register switch to cpuid_entry_get_reg() function
Eduardo Habkost [Thu, 4 Oct 2012 20:48:56 +0000 (17:48 -0300)]
i386: kvm: extract register switch to cpuid_entry_get_reg() function

No behavior change: just code movement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: kvm_arch_get_supported_cpuid: use 'entry' variable
Eduardo Habkost [Thu, 4 Oct 2012 20:48:55 +0000 (17:48 -0300)]
i386: kvm: kvm_arch_get_supported_cpuid: use 'entry' variable

The reg switch will be moved to a separate function, so store the entry
pointer in a variable.

No behavior change, just code movement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: kvm_arch_get_supported_cpuid: clean up has_kvm_features check
Eduardo Habkost [Thu, 4 Oct 2012 20:48:54 +0000 (17:48 -0300)]
i386: kvm: kvm_arch_get_supported_cpuid: clean up has_kvm_features check

Instead of a function-specific has_kvm_features variable, simply use a
"found" variable that will be checked in case we have to use the legacy
get_para_features() interface.

No behavior change, just code cleanup.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoi386: kvm: kvm_arch_get_supported_cpuid: move R_EDX hack outside of for loop
Eduardo Habkost [Thu, 4 Oct 2012 20:48:53 +0000 (17:48 -0300)]
i386: kvm: kvm_arch_get_supported_cpuid: move R_EDX hack outside of for loop

The for loop will become a separate function, so clean it up so it can
become independent from the bit hacking for R_EDX.

No behavior change[1], just code movement.

[1] Well, only if the kernel returned CPUID leafs 1 or 0x80000001 as
    unsupported, but there's no kernel version that does that.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agospapr: Pass PowerPCCPU to hypercalls
Andreas Färber [Thu, 3 May 2012 04:23:01 +0000 (06:23 +0200)]
spapr: Pass PowerPCCPU to hypercalls

Needed for changing cpu_has_work() argument type to CPUState,
used in h_cede().

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agospapr: Pass PowerPCCPU to spapr_hypercall()
Andreas Färber [Thu, 3 May 2012 04:13:14 +0000 (06:13 +0200)]
spapr: Pass PowerPCCPU to spapr_hypercall()

Needed for changing the hypercall handlers' argument type to PowerPCCPU.

Signed-off-by: Andreas Färber <afaerber@suse.de>