]> git.proxmox.com Git - qemu.git/log
qemu.git
13 years agovnc: palette: use a pool to reduce memory allocations
Corentin Chary [Fri, 4 Feb 2011 08:05:58 +0000 (09:05 +0100)]
vnc: palette: use a pool to reduce memory allocations

We now that the palette will never have more than 256
elements. Let's use a pool to reduce malloc calls.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovnc: tight: use the update frequency to choose between lossy and lossless
Corentin Chary [Fri, 4 Feb 2011 08:05:57 +0000 (09:05 +0100)]
vnc: tight: use the update frequency to choose between lossy and lossless

Use the new update frequency infrastructure to use jpeg for regions with
high update frequency.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovnc: refresh lossy rect after a given timeout
Corentin Chary [Fri, 4 Feb 2011 08:05:56 +0000 (09:05 +0100)]
vnc: refresh lossy rect after a given timeout

If an adaptive encoding has choosen to send a lossy update
based on the result of vnc_update_freq(), then it should advertise
it with vnc_sent_lossy_rect(). This will allow to automatically refresh
this rect once it's static again.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovnc: add a way to get the update frequency for a given region
Corentin Chary [Fri, 4 Feb 2011 08:05:55 +0000 (09:05 +0100)]
vnc: add a way to get the update frequency for a given region

This patch compute the update frequency (in Hz) for each 64x64 rects.
Any adaptive encoding can get this value using vnc_update_freq(), and
switch to a lossy encoding if the value is too high.

The frequency is pre-calculated every 500ms, based on the last 10
updates per 64x64 rect.

If a 64x64 rect was not updated in the last 2 second, then the frequency
became 0, and all the stored timestamp are reseted.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovnc: don't set the quality if lossy encoding are disabled
Corentin Chary [Fri, 4 Feb 2011 08:05:54 +0000 (09:05 +0100)]
vnc: don't set the quality if lossy encoding are disabled

This should not change the current behavior, but if any new
encoding try to use the tight quality, it will always be set
to -1 when lossy encodings are disabled.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agomicroblaze: Allow targeting little-endian mb
Edgar E. Iglesias [Mon, 21 Feb 2011 11:42:20 +0000 (12:42 +0100)]
microblaze: Allow targeting little-endian mb

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
13 years agopls3adsp1800: Base load_elf endianness on target endianness
Edgar E. Iglesias [Mon, 21 Feb 2011 11:30:27 +0000 (12:30 +0100)]
pls3adsp1800: Base load_elf endianness on target endianness

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
13 years agodo not use qemu_icount_delta in the !use_icount case
Paolo Bonzini [Mon, 21 Feb 2011 08:51:23 +0000 (09:51 +0100)]
do not use qemu_icount_delta in the !use_icount case

The !use_icount code is the same for iothread and non-iothread,
except that the timeout is different.  Since the timeout might as
well be infinite and is only masking bugs, use the higher value.
With this change the !use_icount code is handled equivalently
in qemu_icount_delta and qemu_calculate_timeout, and we rip it
out of the former.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
13 years agohw/irq.h: Remove unused SetIRQFunc typedef
Peter Maydell [Mon, 21 Feb 2011 14:58:26 +0000 (14:58 +0000)]
hw/irq.h: Remove unused SetIRQFunc typedef

Remove the typedef SetIRQFunc, as it is not used by anything.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoRevert "prep: Disable second IDE channel, as long as ISA IDE emulation doesn't suppor...
Aurelien Jarno [Mon, 21 Feb 2011 14:53:05 +0000 (15:53 +0100)]
Revert "prep: Disable second IDE channel, as long as ISA IDE emulation doesn't support same irq for both channels"

This reverts commit 491e2a338fdf8310c84f6ebaed1683a871a0700e.

13 years agoisa-bus: Remove bogus IRQ sharing check
Jan Kiszka [Sat, 19 Feb 2011 17:56:22 +0000 (18:56 +0100)]
isa-bus: Remove bogus IRQ sharing check

Nothing prevented IRQ sharing on the ISA bus in principle. Not all
boards supported this, neither each and every card nor driver and OS.
Still, there existed valid IRQ sharing scenarios, (at least) two of them
can also be found in QEMU: >2 PC UARTs and the PREP IDE buses.

So remove this artificial restriction from our ISA model.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoPS/2 keyboard Scancode Set 3 support
Roy Tam [Mon, 21 Feb 2011 00:06:32 +0000 (08:06 +0800)]
PS/2 keyboard Scancode Set 3 support

The following patch adds PS/2 keyboard Scancode Set 3 support.

Signed-off-by: Roy Tam <roytam@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix shift by immediate and narrow where src, dest overlap
Peter Maydell [Mon, 21 Feb 2011 11:05:22 +0000 (11:05 +0000)]
target-arm: Fix shift by immediate and narrow where src, dest overlap

For Neon shifts by immediate and narrow, correctly handle the case
where the source registers and the destination registers overlap
(the second pass should use the original register contents, not the
results of the first pass).

This includes a refactoring to pull the size check outside the
loop rather than inside, since there is now very little common
code between the size == 3 and size != 3 case.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Refactor to pull narrowing decode into separate function
Peter Maydell [Mon, 21 Feb 2011 11:05:21 +0000 (11:05 +0000)]
target-arm: Refactor to pull narrowing decode into separate function

Pull the code which decodes narrowing operations as being either
signed/unsigned saturate or plain out into its own function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agow32: Remove implementation of function ffs
Stefan Weil [Fri, 4 Feb 2011 21:38:48 +0000 (22:38 +0100)]
w32: Remove implementation of function ffs

This implementation is no longer needed.

ffs is either a built-in function (for compilations with optimisation)
or taken from libiberty.a (which was added by the previous patch).

Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agow32: Use additional library libiberty.a
Stefan Weil [Fri, 4 Feb 2011 21:38:47 +0000 (22:38 +0100)]
w32: Use additional library libiberty.a

libiberty.a is part of MinGW and provides useful functions
like ffs (MinGW) and getopt (MinGW-w64).

It is needed for w64 compilations and allows simpler code for w32.

Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoFix obvious mistake in pxa2xx i2s driver
Vasily Khoruzhick [Sun, 20 Feb 2011 19:23:59 +0000 (21:23 +0200)]
Fix obvious mistake in pxa2xx i2s driver

RST bit is (1 << 4) bit, not (1 << 3), fix condition
that enables i2s if ENB is set and RST is not set.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agopxa2xx_keypad: Handle 0xe0xx keycodes
Vasily Khoruzhick [Tue, 15 Feb 2011 13:27:29 +0000 (15:27 +0200)]
pxa2xx_keypad: Handle 0xe0xx keycodes

Add handling of 0xe0xx keycodes to pxa2xx_driver.
Extended keycodes in keymap should be marked with most significant
bit set (i.e. 0x80). Without this patch it's not possible to handle
i.e. cursor keys.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agopxa2xx_keypad: enhance emulation of KPAS, KPASMKP regs
Vasily Khoruzhick [Tue, 15 Feb 2011 13:27:28 +0000 (15:27 +0200)]
pxa2xx_keypad: enhance emulation of KPAS, KPASMKP regs

Add emulation of KPAS register and proper emulation of
KPASMKP regs, so now driver supports multipresses and properly
works with Linux driver.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoqdev: Fix printout of bit device properties with bit index >= 8
David 'Digit' Turner [Mon, 10 Jan 2011 22:11:40 +0000 (23:11 +0100)]
qdev: Fix printout of bit device properties with bit index >= 8

Signed-off-by: David 'Digit' Turner <digit@google.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agocheck-qdict: Fix possible crash
Stefan Weil [Fri, 21 Jan 2011 21:50:30 +0000 (22:50 +0100)]
check-qdict: Fix possible crash

This warning is reported by cppcheck:

check-qdict.c:270: warning: scanf without field width limits can crash with huge input data

Fix it by limiting the field widths to 127 (both key and value take
127 characters + a terminating '\0' byte).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotests: Fix two memory leaks
Stefan Weil [Fri, 21 Jan 2011 21:49:29 +0000 (22:49 +0100)]
tests: Fix two memory leaks

Although both leaks are not really important, fix them
to avoid cppcheck warnings:

tests/linux-test.c:433: error: Memory leak: stack1
tests/linux-test.c:433: error: Memory leak: stack2

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoqemu-char: Check for missing backend name
Stefan Hajnoczi [Sat, 22 Jan 2011 13:07:26 +0000 (13:07 +0000)]
qemu-char: Check for missing backend name

Check if the backend option is missing before searching the backend
table.  This fixes a NULL pointer dereference when QEMU is invoked with
the following invalid command-line:

  $ qemu -chardev id=foo,path=/tmp/socket

Previously QEMU would segfault, now it produces this error message:

  chardev: "foo" missing backend

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agos390: Fix memory leak
Stefan Weil [Sat, 22 Jan 2011 12:02:46 +0000 (13:02 +0100)]
s390: Fix memory leak

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoppc405: Fix memory leak
Stefan Weil [Sat, 22 Jan 2011 12:02:45 +0000 (13:02 +0100)]
ppc405: Fix memory leak

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Acked-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agopci: Fix memory leak
Stefan Weil [Sat, 22 Jan 2011 12:02:44 +0000 (13:02 +0100)]
pci: Fix memory leak

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agovhost: disable on tap link down
Michael S. Tsirkin [Wed, 9 Feb 2011 16:45:09 +0000 (18:45 +0200)]
vhost: disable on tap link down

qemu makes it possible to disable link at tap which is not communicated
to the guest but causes all packets to be dropped.

When vhost-net is enabled, vhost needs to be aware of both the virtio
link_down and the peer link_down. we switch to userspace emulation when
either is down.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: pradeep <psuriset@linux.vnet.ibm.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agonet: notify peer about link status change
Michael S. Tsirkin [Wed, 9 Feb 2011 16:45:04 +0000 (18:45 +0200)]
net: notify peer about link status change

qemu makes it possible to disable link at tap which is not communicated
to the guest but causes all packets to be dropped.

This works for virtio userspace, as qemu stops giving it packets, but
not for virtio-net connected to vhost-net as that does not get notified
about this change.

Notify peer when this happens, which will then be used by the follow-up
patch to stop/start vhost-net.

Note: it might be a good idea to make peer link status match tap in this
case, so the guest gets an event and updates the carrier state. For now
stay bug for bug compatible with what we used to have in userspace.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: pradeep <psuriset@linux.vnet.ibm.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agow32: Fix arguments for GetProcessAffinityMask, SetProcessAffinityMask
Stefan Weil [Sat, 5 Feb 2011 19:59:49 +0000 (20:59 +0100)]
w32: Fix arguments for GetProcessAffinityMask, SetProcessAffinityMask

These functions take arguments of type PDWORD_PTR which is a
pointer to a DWORD_PTR, not a pointer to a DWORD.

Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix unsigned VQRSHL by large shift counts
Peter Maydell [Tue, 15 Feb 2011 13:44:49 +0000 (13:44 +0000)]
target-arm: Fix unsigned VQRSHL by large shift counts

Correctly handle VQRSHL of unsigned values by a shift count of the
width of the data type or larger, which must be special-cased in the
qrshl_u* helper functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix signed VQRSHL by large shift counts
Peter Maydell [Tue, 15 Feb 2011 13:44:48 +0000 (13:44 +0000)]
target-arm: Fix signed VQRSHL by large shift counts

Handle the case of signed VQRSHL by a shift count of the width of the
data type or larger, which must be special cased in the qrshl_s*
helper functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: fix decoding of Neon 64 bit shifts.
Christophe Lyon [Tue, 15 Feb 2011 13:44:47 +0000 (13:44 +0000)]
target-arm: fix decoding of Neon 64 bit shifts.

Fix decoding of 64 bits variants of VSHRN, VRSHRN, VQSHRN, VQSHRUN,
VQRSHRN, VQRSHRUN, taking into account whether inputs are unsigned
or not.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: fix Neon VQSHRN and VSHRN.
Christophe Lyon [Tue, 15 Feb 2011 13:44:46 +0000 (13:44 +0000)]
target-arm: fix Neon VQSHRN and VSHRN.

Call the normal shift helpers instead of the rounding ones.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix saturated values for Neon right shifts
Peter Maydell [Tue, 15 Feb 2011 13:44:45 +0000 (13:44 +0000)]
target-arm: Fix saturated values for Neon right shifts

Fix value returned by signed 8 and 16 bit qrshl helpers
when the result has saturated.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: fix unsigned 64 bit right shifts.
Christophe Lyon [Tue, 15 Feb 2011 13:44:44 +0000 (13:44 +0000)]
target-arm: fix unsigned 64 bit right shifts.

Fix range of shift amounts which always give 0 as result.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix unsigned VRSHL.s8 and .s16 right shifts by type width
Christophe Lyon [Tue, 15 Feb 2011 13:44:43 +0000 (13:44 +0000)]
target-arm: Fix unsigned VRSHL.s8 and .s16 right shifts by type width

Fix handling of unsigned VRSHL.s8 and .s16 right shifts by the type
width.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix signed VRSHL by large shift counts
Peter Maydell [Tue, 15 Feb 2011 13:44:42 +0000 (13:44 +0000)]
target-arm: Fix signed VRSHL by large shift counts

Correctly handle VRSHL of signed values by a shift count of the
width of the data type or larger, which must be special-cased in the
rshl_s* helper functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix rounding constant addition for Neon shifts
Christophe Lyon [Tue, 15 Feb 2011 13:44:41 +0000 (13:44 +0000)]
target-arm: Fix rounding constant addition for Neon shifts

Handle cases where adding the rounding constant could overflow in Neon
shift instructions: VRSHR, VRSRA, VQRSHRN, VQRSHRUN, VRSHRN.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
[peter.maydell@linaro.org: fix handling of large shifts in rshl_s32,
calculate signed saturated value as other functions do.]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Move Neon VZIP to helper functions
Peter Maydell [Mon, 14 Feb 2011 10:22:49 +0000 (10:22 +0000)]
target-arm: Move Neon VZIP to helper functions

Move the implementation of the Neon VUZP unzip instruction from inline
code to helper functions. (At 50+ TCG ops it was well over the
recommended limit for coding inline.) The helper implementations also
give the correct answers where the inline implementation did not.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Move Neon VUZP to helper functions
Peter Maydell [Mon, 14 Feb 2011 10:22:48 +0000 (10:22 +0000)]
target-arm: Move Neon VUZP to helper functions

Move the implementation of the Neon VUZP unzip instruction from inline
code to helper functions. (At 50+ TCG ops it was well over the
recommended limit for coding inline.) The helper implementations also
fix the handling of the quadword version of the instruction.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Correct conversion of Thumb Neon dp encodings into ARM
Juha Riihimäki [Fri, 11 Feb 2011 13:35:25 +0000 (13:35 +0000)]
target-arm: Correct conversion of Thumb Neon dp encodings into ARM

We handle Thumb Neon data processing instructions by converting them
into the equivalent ARM encoding, as the two are very close. However
the ARM encoding should have bit 28 set, not clear. This wasn't causing
any problems because we don't actually look at that bit during decode;
however it is better to do the conversion correctly to avoid problems
later if we add checks to UNDEF on SBZ/SBO bits.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix Neon VQDMLSL instruction
Peter Maydell [Fri, 11 Feb 2011 12:26:48 +0000 (12:26 +0000)]
target-arm: Fix Neon VQDMLSL instruction

For VQDMLSL, negation has to occur after saturation, not before.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Refactor handling of VQDMULL
Peter Maydell [Fri, 11 Feb 2011 12:26:47 +0000 (12:26 +0000)]
target-arm: Refactor handling of VQDMULL

Refactor the handling of VQDMULL so that it is dealt with in
its own if() case rather than together with the accumulating
instructions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Implement VMULL.P8
Peter Maydell [Thu, 10 Feb 2011 19:07:55 +0000 (19:07 +0000)]
target-arm: Implement VMULL.P8

Implement VMULL.P8 (the 32x32->64 version of the polynomial multiply
instruction).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoqemu-lock.h: Remove non-pthreads spinlock implementations
Peter Maydell [Mon, 31 Jan 2011 18:26:40 +0000 (18:26 +0000)]
qemu-lock.h: Remove non-pthreads spinlock implementations

Since configure guarantees us that we have pthreads on all hosts
except mingw (which doesn't support a USER_ONLY config), we can
and should use the pthread_mutex based implementation of spin_lock()
and spin_unlock() in all USER_ONLY cases. This means that all the
inline-native-assembly code supporting the "USER_ONLY but not USE_NPTL"
case can go away.

The not-USER_ONLY case remains as empty implementations; there is
no change in behaviour here.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoe1000: verify we have buffers, upfront
Michael S. Tsirkin [Tue, 15 Feb 2011 16:27:55 +0000 (18:27 +0200)]
e1000: verify we have buffers, upfront

The spec says: Any descriptor with a non-zero status byte has been
processed by the hardware, and is ready to be handled by the software.

Thus, once we change a descriptor status to non-zero we should
never move the head backwards and try to reuse this
descriptor from hardware.

This actually happened with a multibuffer packet
that arrives when we don't have enough buffers.

Fix by checking that we have enough buffers upfront
so we never need to discard the packet midway through.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoe1000: clear EOP for multi-buffer descriptors
Michael S. Tsirkin [Tue, 15 Feb 2011 16:27:52 +0000 (18:27 +0200)]
e1000: clear EOP for multi-buffer descriptors

The e1000 spec says: if software statically allocates
buffers, and uses memory read to check for completed descriptors, it
simply has to zero the status byte in the descriptor to make it ready
for reuse by hardware. This is not a hardware requirement (moving the
hardware tail pointer is), but is necessary for performing an in–memory
scan.

Thus the guest does not have to clear the status byte.  In case it
doesn't we need to clear EOP for all descriptors
except the last.  While I don't know of any such guests,
it's probably a good idea to stick to the spec.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Juan Quintela <quintela@redhat.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoe1000: multi-buffer packet support
Michael S. Tsirkin [Tue, 15 Feb 2011 16:27:48 +0000 (18:27 +0200)]
e1000: multi-buffer packet support

e1000 supports multi-buffer packets larger than rxbuf_size.

This fixes the following (on linux):
- in guest: ifconfig eth1 mtu 16110
- in host: ifconfig tap0 mtu 16110
           ping -s 16082 <guest-ip>

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agopc: remove test on TARGET_PHYS_ADDR_BITS == 32
Aurelien Jarno [Wed, 9 Feb 2011 18:35:51 +0000 (19:35 +0100)]
pc: remove test on TARGET_PHYS_ADDR_BITS == 32

Both i386 and x86_64 targets are now using target_phys_bits=64. Remove
useless code.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-i386: set target_phys_bits to 64
Aurelien Jarno [Wed, 9 Feb 2011 18:35:50 +0000 (19:35 +0100)]
target-i386: set target_phys_bits to 64

qemu i386 used to support more than 4GB of RAM through PAE, but it has
been disabled for an unknown reason. Reenable it.

Note that simply running qemu x86_64 and emulating a 32-bit CPU is not
a solution to this problem as it is about 15% slower (it needs to
emulate 64 bit registers even if half of them are not used). On the
other hand, I haven't seen any measurable impact by switching
target_phys_bits to 64.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoMerge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu
Aurelien Jarno [Sun, 20 Feb 2011 13:47:48 +0000 (14:47 +0100)]
Merge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu

* 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu:
  linux-user: correct core dump format
  linux-user: Define target alignment size
  linux-user: Support the epoll syscalls
  linux-user: in linux-user/strace.c, tswap() is useless
  linux-user: add rmdir() strace

13 years agoi8254: convert to qdev
Blue Swirl [Sun, 13 Feb 2011 19:54:40 +0000 (19:54 +0000)]
i8254: convert to qdev

Convert to qdev. Don't expose PITState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agovga-isa: make optional
Blue Swirl [Sun, 13 Feb 2011 14:17:00 +0000 (14:17 +0000)]
vga-isa: make optional

Ignore failure with vga-isa device creation, but print a warning
message.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agovga-isa: convert to qdev
Blue Swirl [Sun, 13 Feb 2011 14:01:05 +0000 (14:01 +0000)]
vga-isa: convert to qdev

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoapplesmc: make optional
Blue Swirl [Sun, 13 Feb 2011 12:31:28 +0000 (12:31 +0000)]
applesmc: make optional

Based on patch by David Ahern.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agofdc: make optional
Blue Swirl [Sat, 12 Feb 2011 22:25:26 +0000 (22:25 +0000)]
fdc: make optional

Ignore failure with fdc device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agofdc: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 16:32:23 +0000 (16:32 +0000)]
fdc: refactor device creation

Turn fdc_init_isa into an inline function.

Get floppy geometry directly from the drives.

Don't expose FDCtrl.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agofdc: use FDriveType for floppy drive type
Blue Swirl [Sat, 12 Feb 2011 21:23:12 +0000 (21:23 +0000)]
fdc: use FDriveType for floppy drive type

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agofdc: move floppy geometry guessing to block.c
Blue Swirl [Sat, 12 Feb 2011 20:43:32 +0000 (20:43 +0000)]
fdc: move floppy geometry guessing to block.c

Other geometry guessing functions already reside in block.c.

Remove some unused or debugging only fields.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoserial: make optional
Blue Swirl [Sat, 5 Feb 2011 21:30:42 +0000 (21:30 +0000)]
serial: make optional

Ignore failure with serial device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoserial: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 19:37:40 +0000 (19:37 +0000)]
serial: refactor device creation

Turn serial_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agone2000_isa: make optional
Blue Swirl [Sat, 5 Feb 2011 15:44:45 +0000 (15:44 +0000)]
ne2000_isa: make optional

Ignore failure with ne2000_isa device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agone2000_isa: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 15:39:57 +0000 (15:39 +0000)]
ne2000_isa: refactor device creation

Turn isa_ne2000_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoparallel: make optional
Blue Swirl [Sat, 5 Feb 2011 14:56:53 +0000 (14:56 +0000)]
parallel: make optional

Ignore failure with parallel device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoparallel: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 14:51:57 +0000 (14:51 +0000)]
parallel: refactor device creation

Turn parallel_init into an inline function.

Don't expose ParallelState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoFix vmport segfault (v2)
Marcelo Tosatti [Thu, 17 Feb 2011 03:27:19 +0000 (01:27 -0200)]
Fix vmport segfault (v2)

Fix regression caused by qdev conversion.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agolinux-user: correct core dump format
Laurent Vivier [Sun, 13 Feb 2011 22:37:35 +0000 (23:37 +0100)]
linux-user: correct core dump format

This patch allows to really use the core dumped by qemu with guest
architecture tools.

- it adds a missing bswap_phdr() for the program headers
  of memory regions.

  "objdump -x" sample:

BEFORE:

0x1000000 off    0x00200000 vaddr 0x00000400 paddr 0x00000000 align 2**21
         filesz 0x00000000 memsz 0x00100000 flags ---
0x1000000 off    0x00200000 vaddr 0x00100400 paddr 0x00000000 align 2**21
         filesz 0x00000000 memsz 0x00080000 flags --- 6000000

AFTER:

    LOAD off    0x00002000 vaddr 0x00040000 paddr 0x00000000 align 2**13
         filesz 0x00000000 memsz 0x00001000 flags ---
    LOAD off    0x00002000 vaddr 0x00041000 paddr 0x00000000 align 2**13
         filesz 0x00000000 memsz 0x00000800 flags rw-

- it doesn't pad the note size to sizeof(int32_t).
  On m68k the NT_PRSTATUS note size is 154 and
  must not be rounded up to 156, because this value is checked by
  objdump and gdb.

  "gdb" symptoms:

      "warning: Couldn't find general-purpose registers in core file."

  "objdump -x" sample:

BEFORE:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 note0         000001c4  00000000  00000000  000003b4  2**0
                  CONTENTS, READONLY
  1 .auxv         00000070  00000000  00000000  00000508  2**2
                  CONTENTS
  2 proc1         00100000  00000400  00000000  00200000  2**10
                  READONLY

AFTER:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 note0         000001c4  00000000  00000000  000003b4  2**0
                  CONTENTS, READONLY
  1 .reg/19022    00000050  00000000  00000000  0000040e  2**2
                  CONTENTS
  2 .reg          00000050  00000000  00000000  0000040e  2**2
                  CONTENTS
  3 .auxv         00000070  00000000  00000000  00000508  2**2
                  CONTENTS
  4 load1         00000000  00040000  00000000  00002000  2**13
                  ALLOC, READONLY

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: Define target alignment size
Laurent Vivier [Sun, 13 Feb 2011 22:37:34 +0000 (23:37 +0100)]
linux-user: Define target alignment size

Datatype alignment can be found using following application:

int main(void)
{
printf("alignof(short) %ld\n", __alignof__(short));
printf("alignof(int) %ld\n", __alignof__(int));
printf("alignof(long) %ld\n", __alignof__(long));
printf("alignof(long long) %ld\n", __alignof__(long long));
}

This patch includes following alignments:

i386

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 8

 x86_64

   alignof(short) 2
   alignof(int) 4
   alignof(long) 8
   alignof(long long) 8

 arm

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 4

 m68k (680x0)

   alignof(short) 2
   alignof(int) 2
   alignof(long) 2
   alignof(long long) 2

 mips

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 8

 ppc

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 8

for other targets, use by default (2,4,4,8).

Please, update for your favorite target...

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: Support the epoll syscalls
Peter Maydell [Tue, 15 Feb 2011 18:35:05 +0000 (18:35 +0000)]
linux-user: Support the epoll syscalls

Support the epoll family of syscalls: epoll_create(), epoll_create1(),
epoll_ctl(), epoll_wait() and epoll_pwait(). Note that epoll_create1()
and epoll_pwait() are later additions, so we have to test separately
in configure for their presence.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: in linux-user/strace.c, tswap() is useless
Laurent Vivier [Tue, 15 Feb 2011 20:10:44 +0000 (21:10 +0100)]
linux-user: in linux-user/strace.c, tswap() is useless

Syscall parameters are already swapped by the caller.

This patch removes useless tswap() from strace.c

$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...

without tswap()

...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...

natively:

$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...

$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agolinux-user: add rmdir() strace
Laurent Vivier [Tue, 15 Feb 2011 20:10:43 +0000 (21:10 +0100)]
linux-user: add rmdir() strace

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
13 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Wed, 16 Feb 2011 14:47:13 +0000 (08:47 -0600)]
Merge remote branch 'kwolf/for-anthony' into staging

13 years agoMerge remote branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Wed, 16 Feb 2011 14:47:07 +0000 (08:47 -0600)]
Merge remote branch 'qemu-kvm/uq/master' into staging

13 years agoHandle icount for powerpc tbl/tbu/decr load and store.
Tristan Gingold [Tue, 15 Feb 2011 08:39:54 +0000 (09:39 +0100)]
Handle icount for powerpc tbl/tbu/decr load and store.

Handle option '-icount X' on powerpc targets.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
13 years agoMerge mainstone.h header into mainstone.c
Dmitry Eremin-Solenikov [Sat, 12 Feb 2011 00:15:25 +0000 (03:15 +0300)]
Merge mainstone.h header into mainstone.c

Now the only user of mainstone.h is mainstone.c file. Merge header
into board file.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agomainstone: convert FPGA emulation code to use QDev/SysBus
Dmitry Eremin-Solenikov [Sat, 12 Feb 2011 00:15:24 +0000 (03:15 +0300)]
mainstone: convert FPGA emulation code to use QDev/SysBus

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agomainstone: correct and simplify irq handling
Dmitry Eremin-Solenikov [Sat, 12 Feb 2011 00:15:23 +0000 (03:15 +0300)]
mainstone: correct and simplify irq handling

Simplify IRQ handling to stop setting an input irq pin. As a win, also get
correct IRQ status after save/load cycle.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoFix build from previous commit
Anthony Liguori [Mon, 14 Feb 2011 20:24:24 +0000 (14:24 -0600)]
Fix build from previous commit

I unfortunately got on an unnamed branch and pushed the wrong bits

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoPATCH] slirp: fix buffer overrun
Bruce Rogers [Sat, 5 Feb 2011 21:47:56 +0000 (14:47 -0700)]
PATCH] slirp: fix buffer overrun

Since the addition of the slirp member to struct mbuf, the value of
SLIRP_MSIZE and the initialization of m_size have not been correct,
resulting in overrunning the end of the malloc'd buffer in some cases.

Signed-off-by: Bruce Rogers <brogers@novell.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agocorrectly check ppr priority during interrupt injection]
Gleb Natapov [Mon, 7 Feb 2011 14:14:44 +0000 (16:14 +0200)]
correctly check ppr priority during interrupt injection]

TPR blocks all interrupts in a priority class, so simple "less or
equal" check is not enough.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoio-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond
Anthony Liguori [Tue, 8 Feb 2011 17:18:18 +0000 (18:18 +0100)]
io-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agokvm: x86: Introduce kvmclock device to save/restore its state
Jan Kiszka [Mon, 7 Feb 2011 11:19:26 +0000 (12:19 +0100)]
kvm: x86: Introduce kvmclock device to save/restore its state

If kvmclock is used, which implies the kernel supports it, register a
kvmclock device with the sysbus. Its main purpose is to save and restore
the kernel state on migration, but this will also allow to visualize it
one day.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Glauber Costa <glommer@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Make kvm_state globally available
Jan Kiszka [Mon, 7 Feb 2011 11:19:25 +0000 (12:19 +0100)]
kvm: Make kvm_state globally available

KVM-assisted devices need access to it but we have no clean channel to
distribute a reference. As a workaround until there is a better
solution, export kvm_state for global use, though use should remain
restricted to the mentioned scenario.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agocirrus: Remove obsolete kvm.h include
Jan Kiszka [Mon, 7 Feb 2011 11:19:24 +0000 (12:19 +0100)]
cirrus: Remove obsolete kvm.h include

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoIntroduce log_start/log_stop in CPUPhysMemoryClient
Anthony PERARD [Mon, 7 Feb 2011 11:19:23 +0000 (12:19 +0100)]
Introduce log_start/log_stop in CPUPhysMemoryClient

In order to use log_start/log_stop with Xen as well in the vga code,
this two operations have been put in CPUPhysMemoryClient.

The two new functions cpu_physical_log_start,cpu_physical_log_stop are
used in hw/vga.c and replace the kvm_log_start/stop. With this, vga does
no longer depends on kvm header.

[ Jan: rebasing and style fixlets ]

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Remove unneeded memory slot reservation
Jan Kiszka [Mon, 7 Feb 2011 11:19:22 +0000 (12:19 +0100)]
kvm: Remove unneeded memory slot reservation

The number of slots and the location of private ones changed several
times in KVM's early days. However, it's stable since 2.6.29 (our
required baseline), and slots 8..11 are no longer reserved since then.
So remove this unneeded restriction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: x86: Catch and report failing IRQ and NMI injections
Jan Kiszka [Mon, 7 Feb 2011 11:19:21 +0000 (12:19 +0100)]
kvm: x86: Catch and report failing IRQ and NMI injections

We do not need to abort, but the user should be notified that weird
things go on.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Drop return values from kvm_arch_pre/post_run
Jan Kiszka [Mon, 7 Feb 2011 11:19:20 +0000 (12:19 +0100)]
kvm: Drop return values from kvm_arch_pre/post_run

We do not check them, and the only arch with non-empty implementations
always returns 0 (this is also true for qemu-kvm).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Alexander Graf <agraf@suse.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: x86: Prepare VCPU loop for in-kernel irqchip
Jan Kiszka [Mon, 7 Feb 2011 11:19:19 +0000 (12:19 +0100)]
kvm: x86: Prepare VCPU loop for in-kernel irqchip

Effectively no functional change yet as kvm_irqchip_in_kernel still only
returns 0, but this patch will allow qemu-kvm to adopt the VCPU loop of
upsteam KVM.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Separate TCG from KVM cpu execution
Jan Kiszka [Mon, 7 Feb 2011 11:19:18 +0000 (12:19 +0100)]
kvm: Separate TCG from KVM cpu execution

Mixing up TCG bits with KVM already led to problems around eflags
emulation on x86. Moreover, quite some code that TCG requires on cpu
enty/exit is useless for KVM. So dispatch between tcg_cpu_exec and
kvm_cpu_exec as early as possible.

The core logic of cpu_halted from cpu_exec is added to
kvm_arch_process_irqchip_events. Moving away from cpu_exec makes
exception_index meaningless for KVM, we can simply pass the exit reason
directly (only "EXCP_DEBUG vs. rest" is relevant).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoMove debug exception handling out of cpu_exec
Jan Kiszka [Mon, 7 Feb 2011 11:19:17 +0000 (12:19 +0100)]
Move debug exception handling out of cpu_exec

To prepare splitting up KVM and TCG CPU entry/exit, move the debug
exception into cpus.c and invoke cpu_handle_debug_exception on return
from qemu_cpu_exec.

This also allows to clean up the debug request signaling: We can assign
the job of informing main-loop to qemu_system_debug_request and stop the
calling cpu directly in cpu_handle_debug_exception. That means a debug
stop will now only be signaled via debug_requested and not additionally
via vmstop_requested.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoRefactor debug and vmstop request interface
Jan Kiszka [Mon, 7 Feb 2011 11:19:16 +0000 (12:19 +0100)]
Refactor debug and vmstop request interface

Instead of fiddling with debug_requested and vmstop_requested directly,
introduce qemu_system_debug_request and turn qemu_system_vmstop_request
into a public interface. This aligns those services with exiting ones in
vl.c.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoImprove vm_stop reason declarations
Jan Kiszka [Wed, 9 Feb 2011 15:29:40 +0000 (16:29 +0100)]
Improve vm_stop reason declarations

Define and use dedicated constants for vm_stop reasons, they actually
have nothing to do with the EXCP_* defines used so far. At this chance,
specify more detailed reasons so that VM state change handlers can
evaluate them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoFix a few coding style violations in cpus.c
Jan Kiszka [Mon, 7 Feb 2011 11:19:14 +0000 (12:19 +0100)]
Fix a few coding style violations in cpus.c

No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoRefactor cpu_has_work/any_cpu_has_work in cpus.c
Jan Kiszka [Wed, 9 Feb 2011 15:29:37 +0000 (16:29 +0100)]
Refactor cpu_has_work/any_cpu_has_work in cpus.c

Avoid duplicate use of the function name cpu_has_work, it's confusing,
also their scope. Refactor cpu_has_work to cpu_thread_is_idle and do the
same with any_cpu_has_work.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoRefactor kvm&tcg function names in cpus.c
Jan Kiszka [Mon, 7 Feb 2011 11:19:12 +0000 (12:19 +0100)]
Refactor kvm&tcg function names in cpus.c

Pure interface cosmetics: Ensure that only kvm core services (as
declared in kvm.h) start with "kvm_". Prepend "qemu_" to those that
violate this rule in cpus.c. Also rename the corresponding tcg functions
for the sake of consistency.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: make tsc stable over migration and machine start
Glauber Costa [Thu, 3 Feb 2011 19:19:53 +0000 (14:19 -0500)]
kvm: make tsc stable over migration and machine start

If the machine is stopped, we should not record two different tsc values
upon a save operation. The same problem happens with kvmclock.

But kvmclock is taking a different diretion, being now seen as a separate
device. Since this is unlikely to happen with the tsc, I am taking the
approach here of simply registering a handler for state change, and
using a per-CPUState variable that prevents double updates for the TSC.

Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN
Jan Kiszka [Tue, 1 Feb 2011 21:16:02 +0000 (22:16 +0100)]
kvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN

The reset we issue on KVM_EXIT_SHUTDOWN implies that we should also
leave the VCPU loop. As we now check for exit_request which is set by
qemu_system_reset_request, this bug is no longer critical. Still it's an
unneeded extra turn.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Remove static return code of kvm_handle_io
Jan Kiszka [Tue, 1 Feb 2011 21:16:01 +0000 (22:16 +0100)]
kvm: Remove static return code of kvm_handle_io

Improve the readability of the exit dispatcher by moving the static
return value of kvm_handle_io to its caller.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Unconditionally reenter kernel after IO exits
Jan Kiszka [Tue, 1 Feb 2011 21:16:00 +0000 (22:16 +0100)]
kvm: Unconditionally reenter kernel after IO exits

KVM requires to reenter the kernel after IO exits in order to complete
instruction emulation. Failing to do so will leave the kernel state
inconsistently behind. To ensure that we will get back ASAP, we issue a
self-signal that will cause KVM_RUN to return once the pending
operations are completed.

We can move kvm_arch_process_irqchip_events out of the inner VCPU loop.
The only state that mattered at its old place was a pending INIT
request. Catch it in kvm_arch_pre_run and also trigger a self-signal to
process the request on next kvm_cpu_exec.

This patch also fixes the missing exit_request check in kvm_cpu_exec in
the CONFIG_IOTHREAD case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>