]> git.proxmox.com Git - qemu.git/log
qemu.git
13 years agolm32: add Milkymist Minimac support
Michael Walle [Mon, 7 Mar 2011 22:32:35 +0000 (23:32 +0100)]
lm32: add Milkymist Minimac support

This patch adds support for Milkymist's minimal Ethernet MAC.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agolm32: add Milkymist memory card support
Michael Walle [Mon, 7 Mar 2011 22:32:34 +0000 (23:32 +0100)]
lm32: add Milkymist memory card support

This patch adds support for Milkymist's memory card core.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agolm32: add Milkymist HPDMC support
Michael Walle [Mon, 7 Mar 2011 22:32:33 +0000 (23:32 +0100)]
lm32: add Milkymist HPDMC support

This patch adds support for the Milkymist's High Performance Dynamic Memory
Controller. This is just a dumb model without any functionality. While the
real hardware acts for example as a bridge between software and hardware
for sending SDRAM commans, this model will only eat up these commands and
always returns the expected hardware states, eg. PLL locked etc.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agolm32: add Milkymist AC97 support
Michael Walle [Mon, 7 Mar 2011 22:32:32 +0000 (23:32 +0100)]
lm32: add Milkymist AC97 support

This patch adds support for the Milkymist AC97 compatible sound output and
input core.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agoRevert "ioapic: when switches to level trigger mode, interrupts raised repeatedly."
Aurelien Jarno [Mon, 4 Apr 2011 05:14:03 +0000 (07:14 +0200)]
Revert "ioapic: when switches to level trigger mode, interrupts raised repeatedly."

This reverts commit 9bcfc7daabb138b0fe3d64d74892942d482e5bbd.

13 years agos390x: enable CPU_QuadU
Ulrich Hecht [Tue, 29 Mar 2011 13:29:34 +0000 (15:29 +0200)]
s390x: enable CPU_QuadU

S390x uses the QuadU type, so let's enable it.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agos390x: Enable nptl for s390x
Ulrich Hecht [Tue, 29 Mar 2011 13:29:33 +0000 (15:29 +0200)]
s390x: Enable nptl for s390x

S390x user emulation can do nptl. Reflect this in the configure script.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agos390x: Enable disassembler for s390x
Ulrich Hecht [Tue, 29 Mar 2011 13:29:32 +0000 (15:29 +0200)]
s390x: Enable disassembler for s390x

This patch enables the instruction disassembler when using an
S390x target.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agos390x: fix s390-virtio-serial
Alexander Graf [Tue, 29 Mar 2011 13:29:31 +0000 (15:29 +0200)]
s390x: fix s390-virtio-serial

Commit 6b331efb733a0f913ddc0b7762a1307dec304061 broke the s390 proxy version
of virtio-serial by only taking its PCI brother into account.

So let's adjust s390-virtio-serial the same way as its PCI counterpart, making
it compile and work again.

Signed-off-by: Alexander Graf <agraf@suse.de>
CC: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agos390x: fix KVM target
Alexander Graf [Tue, 29 Mar 2011 13:29:30 +0000 (15:29 +0200)]
s390x: fix KVM target

During Jan's rework of the generic KVM layer, he added some more error checks
and actually aborted if something went wrong. Unfortunately, one of the s390
internal error codes slipped through, aborting the VM without needing to.

This patch fixes booting of S390x virtual machines in KVM.

Signed-off-by: Alexander Graf <agraf@suse.de>
CC: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agovirtio: use generic name when possible
Alexander Graf [Tue, 29 Mar 2011 13:29:29 +0000 (15:29 +0200)]
virtio: use generic name when possible

We have two different virtio buses: pci and s390. The abstraction path
taken in qemu is to have generic aliases for each device type in the
architecture specific qdev devices.

So let's make use of these aliases whenever we can and define them
whenever we can.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoOnly build ivshmem when CONFIG_PCI && CONFIG_KVM
Alexander Graf [Tue, 29 Mar 2011 13:29:28 +0000 (15:29 +0200)]
Only build ivshmem when CONFIG_PCI && CONFIG_KVM

The ivshmem depends on PCI and KVM, not only KVM. Reflect this
in the Makefile, so we don't get build errors on s390x.

Signed-off-by: Alexander Graf <agraf@suse.de>
CC: Cam Macdonell <cam@cs.ualberta.ca>
CC: Juan Quintela <quintela@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agow32: Fix compilation (wrong include file)
Stefan Weil [Sun, 3 Apr 2011 06:55:35 +0000 (08:55 +0200)]
w32: Fix compilation (wrong include file)

arpa/inet.h is not available for w32, so commit
edbb21363fbfe40e050f583df921484cbc31c79d breaks
w32 compilations.

This is fixed by using qemu_socket.h.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoregister signal handler after initializing SDL.
Gleb Natapov [Thu, 31 Mar 2011 09:27:23 +0000 (11:27 +0200)]
register signal handler after initializing SDL.

SDL library initialization mangles signal handlers, so QEMU should
register them after initializing SDL. This was the case before and code
even have a comment about that. Fix it to be so again.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agovl.c: Tidy up message printed when we exit on a signal
Peter Maydell [Wed, 30 Mar 2011 21:03:38 +0000 (22:03 +0100)]
vl.c: Tidy up message printed when we exit on a signal

Tidy up the message printed when qemu exits due to a signal, so that
it's clearer where the message is coming from and that it's not just
stray debug output.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agonet: Remove unused net-checksum.c file
Stefan Hajnoczi [Mon, 28 Mar 2011 21:00:30 +0000 (22:00 +0100)]
net: Remove unused net-checksum.c file

The common checksum functions were moved to net/checksum.c in commit
7200ac3c7c8eefe574193b49eeff09f120e11ec7 but the original net-checksum.c
was never deleted from the source tree.  Remove it now since all users
of the checksum functions link against net/checksum.o and net-checksum.c
is not even compiled anymore.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoe1000: Mask out lower bits of RDBAL/TDBAL
Kevin Wolf [Sat, 26 Mar 2011 18:37:56 +0000 (19:37 +0100)]
e1000: Mask out lower bits of RDBAL/TDBAL

Rx and Tx descriptors are 16 byte aligned, so the lower bits are
ignored by real hardware. In fact, they always read back as zero on real
hardware, but probably nobody relies on that.

Signed-off-by: Kevin Wolf <mail@kevin-wolf.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agogdbstub: Catch and report more vmstop reasons
Jan Kiszka [Tue, 22 Mar 2011 10:02:09 +0000 (11:02 +0100)]
gdbstub: Catch and report more vmstop reasons

When the VM goes into stop state while there is a gdb frontend attached,
it makes sense to inform gdb about this fact and at least a bit about
the stop reason. Basically, all stops are interesting except for the
temporary VMSTOP_SAVE/LOADVM.

The patch maps the relevant VMSTOP reasons on unique and more or less
associatable signals that gdb understands.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotests/cris: Fix some errors and potential crashes
Stefan Weil [Sun, 3 Apr 2011 19:36:36 +0000 (21:36 +0200)]
tests/cris: Fix some errors and potential crashes

These errors were reported by cppcheck:

tests/cris/check_openpf1.c:30: error:
Mismatching allocation and deallocation: f

tests/cris/check_openpf2.c:13: error:
Mismatching allocation and deallocation: f

tests/cris/check_stat3.c:16: error:
Buffer overrun possible for long cmd-line args

tests/cris/check_stat4.c:18: error:
Buffer overrun possible for long cmd-line args

The first two are obvious coding errors (fopen needs fclose, not close).

The last two may seem less important (nobody will start test code
with an argument of more than 1022 characters which raises a buffer
overrun). Fixing them nevertheless helps with static code checks
like those done by cppcheck.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agoioapic: when switches to level trigger mode, interrupts raised repeatedly.
Isaku Yamahata [Wed, 16 Mar 2011 09:05:01 +0000 (18:05 +0900)]
ioapic: when switches to level trigger mode, interrupts raised repeatedly.

- the trigger mode is edge at first
- During initializatoin, the interrupt is raised as edge which is masked.
  The corresponding bit of irr is set.
- Then the mode is switched to level and it's unmasked.
- the bit of irr is set, so the interrupt is raised repeatedly by
  ioapic_service().
- OS considers that the irq line is broken and falls back to polling mode.

This patch fixes the issues.
After raising edige, clear the bit of irr.

> Bringing up interface eth0:
> Determining IP information for eth0...irq 18: nobody cared (try booting with the "irqpoll" option)
> Pid: 4126, comm: ip Not tainted 2.6.38-rc7 #1
> Call Trace:
>  <IRQ>  [<ffffffff8105b009>] ? __report_bad_irq+0x38/0x87
>  [<ffffffff8105b177>] ? note_interrupt+0x11f/0x188
>  [<ffffffff8105bacf>] ? handle_fasteoi_irq+0xa7/0xd1
>  [<ffffffff810046ff>] ? handle_irq+0x83/0x8c
>  [<ffffffff81003eb9>] ? do_IRQ+0x48/0xaf
>  [<ffffffff81300513>] ? ret_from_intr+0x0/0xe
>  [<ffffffff81031ab8>] ? __do_softirq+0x4f/0x114
>  [<ffffffff81002d6c>] ? call_softirq+0x1c/0x28
>  [<ffffffff81004647>] ? do_softirq+0x33/0x68
>  [<ffffffff810316fb>] ? irq_exit+0x36/0x38
>  [<ffffffff81015f2c>] ? smp_apic_timer_interrupt+0x88/0x96
>  [<ffffffff81002853>] ? apic_timer_interrupt+0x13/0x20
>  <EOI>  [<ffffffff810177ed>] ? __ioapic_set_affinity+0x68/0x7c
>  [<ffffffff813000f0>] ? _raw_spin_unlock_irqrestore+0x8/0xa
>  [<ffffffff8105a84f>] ? __setup_irq+0x224/0x2cb
>  [<ffffffff8120e3c5>] ? e1000_intr+0x0/0x103
>  [<ffffffff8105a9c7>] ? request_threaded_irq+0xd1/0x114
>  [<ffffffff8120e396>] ? e1000_request_irq+0x34/0x63
>  [<ffffffff8121237d>] ? e1000_open+0x81/0x11f
>  [<ffffffff8129097c>] ? call_netdevice_notifiers+0x45/0x4a
>  [<ffffffff81290d8d>] ? __dev_open+0x97/0xc4
>  [<ffffffff8128e9c5>] ? __dev_change_flags+0xb9/0x13d
>  [<ffffffff81290cc1>] ? dev_change_flags+0x1c/0x51
>  [<ffffffff812d0542>] ? devinet_ioctl+0x26e/0x594
>  [<ffffffff812d174c>] ? inet_ioctl+0x92/0xaa
>  [<ffffffff81281d75>] ? T.1003+0x13/0x32
>  [<ffffffff81282152>] ? sock_ioctl+0x1f2/0x1ff
>  [<ffffffff810ae2d3>] ? do_vfs_ioctl+0x498/0x4e7
>  [<ffffffff81281203>] ? sock_alloc_file+0xb3/0x115
>  [<ffffffff8109f79f>] ? fd_install+0x31/0x5d
>  [<ffffffff810ae364>] ? sys_ioctl+0x42/0x65
>  [<ffffffff81001f3b>] ? system_call_fastpath+0x16/0x1b
> handlers:
> [<ffffffff8120e3c5>] (e1000_intr+0x0/0x103)
> Disabling IRQ #18

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoFix trivial "endianness bugs"
Stefan Weil [Sun, 13 Mar 2011 14:44:02 +0000 (15:44 +0100)]
Fix trivial "endianness bugs"

Replace endianess -> endianness.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agohw/vexpress.c: Add model of ARM Versatile Express board
Peter Maydell [Mon, 7 Mar 2011 11:10:32 +0000 (11:10 +0000)]
hw/vexpress.c: Add model of ARM Versatile Express board

Add a model of the ARM Versatile Express board (with A9MPx4
daughterboard).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm/helper.c: For float-int conversion helpers pass ints as ints
Peter Maydell [Mon, 14 Mar 2011 07:23:11 +0000 (07:23 +0000)]
target-arm/helper.c: For float-int conversion helpers pass ints as ints

Correct the argument and return types for the float<->int conversion helper
functions so that integer arguments and return values are declared as
uint32_t/uint64_t, not float32/float64. This allows us to remove the
hand-rolled functions which were doing bitwise copies between the types
via unions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Use new softfloat min/max functions for VMAX, VMIN
Peter Maydell [Fri, 11 Mar 2011 08:12:26 +0000 (08:12 +0000)]
target-arm: Use new softfloat min/max functions for VMAX, VMIN

Use the new softfloat min/max functions to implement the Neon VMAX
and VMIN instructions. This allows us to get the right behaviour
for NaN and negative zero.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Add float*_min() and float*_max() functions
Peter Maydell [Fri, 11 Mar 2011 08:12:25 +0000 (08:12 +0000)]
softfloat: Add float*_min() and float*_max() functions

Add min and max operations to softfloat. This allows us to implement
propagation of NaNs and handling of negative zero correctly (unlike
the approach of having target helper routines return one of the operands
based on the result of a comparison op).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Correct ABD's handling of negative zeroes
Peter Maydell [Fri, 11 Mar 2011 08:12:24 +0000 (08:12 +0000)]
target-arm: Correct ABD's handling of negative zeroes

Implement ABD by taking the absolute value of the difference
of the operands (as the ARM ARM specifies) rather than by
flipping the order of the operands to the subtract based
on the results of a comparison. The latter approch gives
the wrong answers for some edge cases like negative zero.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix VCLE.F32 #0, VCLT.F32 #0 NaN handling
Peter Maydell [Fri, 11 Mar 2011 08:12:23 +0000 (08:12 +0000)]
target-arm: Fix VCLE.F32 #0, VCLT.F32 #0 NaN handling

Implementing the floating-point versions of VCLE #0 and VCLT #0 by
doing a GT comparison and inverting the result gives the wrong
result if the input is a NaN. Implement as a GT comparison with the
operands swapped instead.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Return right result for Neon comparison with NaNs
Peter Maydell [Fri, 11 Mar 2011 08:12:22 +0000 (08:12 +0000)]
target-arm: Return right result for Neon comparison with NaNs

Fix the helper functions implementing the Neon floating point comparison
ops (VCGE, VCGT, VCEQ, VACGT, VACGE) to return the right answer when
one of the values being compared is a NaN.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm/neon_helper.c: Use make_float32/float32_val macros
Peter Maydell [Fri, 11 Mar 2011 08:12:21 +0000 (08:12 +0000)]
target-arm/neon_helper.c: Use make_float32/float32_val macros

Use the softfloat make_float32 and float32_val macros to convert between
softfloat's float32 type and raw uint32_t types, rather than private
conversion functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoccid: add docs
Alon Levy [Sun, 12 Dec 2010 16:13:34 +0000 (18:13 +0200)]
ccid: add docs

Add documentation for the usb-ccid device and accompanying two card
devices, ccid-card-emulated and ccid-card-passthru.

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoccid: add ccid-card-emulated device
Alon Levy [Sun, 24 Oct 2010 10:09:18 +0000 (12:09 +0200)]
ccid: add ccid-card-emulated device

This devices uses libcacard (internal) to emulate a smartcard conforming
to the CAC standard. It attaches to the usb-ccid bus. Usage instructions
(example command lines) are in the following patch in docs/ccid.txt. It
uses libcacard which uses nss, so it can work with both hw cards and
certificates (files).

Signed-off-by: Alon Levy <alevy@redhat.com>
---

changes from v20->v21: (Jes Sorenson review)
 * cosmetics
 * use qemu-thread and qemu_malloc/qemu_free

changes from v19->v20:
 * checkpatch.pl

changes from v18->v19:
 * add qdev.desc
 * backend: drop the enumeration property, back to using a string one.

changes from v16->v17:
 * use PROP_TYPE_ENUM for backend

changes from v15->v16:
 * fix error reporting in initfn
 * bump copyright year
 * update copyright license

changes from v1:
 * remove stale comments, use only c-style comments
 * bugfix, forgot to set recv_len
 * change reader name to 'Virtual Reader'

13 years agolibcacard: add docs
Robert Relyea [Thu, 17 Mar 2011 14:39:46 +0000 (16:39 +0200)]
libcacard: add docs

13 years agolibcacard: add vscclient
Robert Relyea [Thu, 17 Mar 2011 14:38:30 +0000 (16:38 +0200)]
libcacard: add vscclient

client to talk to ccid-card-passthru and use smartcard on client to
perform actual operations.

v23->v24 changes: (Jes Sorensen review 2)
 * use qemu_socket instead of socket
 * use fprintf(stderr,..) for errors
 * remove unneccessary includes since using qemu_common.h

13 years agolibcacard: initial commit
Robert Relyea [Sun, 28 Nov 2010 14:36:38 +0000 (16:36 +0200)]
libcacard: initial commit

libcacard emulates a Common Access Card (CAC) which is a standard
for smartcards. It is used by the emulated ccid card introduced in
a following patch. Docs are available in docs/libcacard.txt

Signed-off-by: Alon Levy <alevy@redhat.com>
---

changes from v24->v25:
 * Fix out of tree builds.
 * Fix build with linux-user targets.

changes from v23->v24: (Jes Sorensen review 2)
 * Makefile.target: use obj-$(CONFIG_*) +=
 * remove unrequired includes, include qemu-common before qemu-thread
  * required adding #define NO_NSPR_10_SUPPORT (harmless)

changes from v22->v23:
 * configure fixes: (reported by Stefan Hajnoczi)
  * test a = b, not a == b (second isn't portable)
  * quote $source_path in case it contains spaces
   - this doesn't really help since there are many other places
     that need similar fixes, not introduced by this patch.

changes from v21->v22:
 * fix configure to not link libcacard if nss not found
    (reported by Stefan Hajnoczi)
 * fix vscclient linkage with simpletrace backend
    (reported by Stefan Hajnoczi)
 * card_7816.c: add missing break in ERROR_DATA_NOT_FOUND
    (reported by William van de Velde)

changes from v20->v21: (Jes Sorensen review)
 * use qemu infrastructure: qemu-thread, qemu-common (qemu_malloc
  and qemu_free), error_report
 * assert instead of ASSERT
 * cosmetic fixes
 * use strpbrk and isspace
 * add --disable-nss --enable-nss here, instead of in the final patch.
 * split vscclient, passthru and docs to following patches.

changes from v19->v20:
 * checkpatch.pl

changes from v15->v16:

Build:
 * don't erase self with distclean
 * fix make clean after make distclean
 * Makefile: make vscclient link quiet

Behavioral:
 * vcard_emul_nss: load coolkey in more situations
 * vscclient:
  * use hton,ntoh
  * send init on connect, only start vevent thread on response
  * read payload after header check, before type switch
  * remove Reconnect
  * update for vscard_common changes, empty Flush implementation

Style/Whitespace:
 * fix wrong variable usage
 * remove unused variable
 * use only C style comments
  * add copyright header
  * fix tabulation

Signed-off-by: Alon Levy <alevy@redhat.com>
libcacard: fix out of tree builds

13 years agoccid: add passthru card device
Alon Levy [Sun, 17 Oct 2010 11:10:32 +0000 (13:10 +0200)]
ccid: add passthru card device

The passthru ccid card is a device sitting on the usb-ccid bus and
using a chardevice to communicate with a remote device using the
VSCard protocol defined in libcacard/vscard_common.h

Usage docs available in following patch in docs/ccid.txt

Signed-off-by: Alon Levy <alevy@redhat.com>
---

Changes from v23->v24:
 * fixed double license line in header.

Changes from v20->v21: (Jes Sorensen review)
 * add reference to COPYING in header
 * long comment reformatting

Changes from v19->v20:
 * checkpatch.pl

Changes from v18->v19:
 * add qdev.desc
 * remove .qdev.unplug (no hot unplug support for ccid bus)

Changes from v16->v17:
 * fix wrong cast when receiving VSC_Error
 * ccid-card-passthru: force chardev user wakeup by sending Init
   see lengthy comment below.

Changes from v15->v16:

Behavioral changes:
 * return correct size
 * return error instead of assert if client sent too large ATR
 * don't assert if client sent too large a size, but add asserts for indices to buffer
 * reset vscard_in indices on chardev disconnect
 * handle init from client
 * error if no chardev supplied
 * use ntoh, hton
 * eradicate reader_id_t
 * remove Reconnect usage (removed from VSCARD protocol)
 * send VSC_SUCCESS on card insert/remove and reader add/remove

Style fixes:
 * width of line fix
 * update copyright
 * remove old TODO's
 * update file header comment
 * use macros for debug levels
 * c++ style comment replacement
 * update copyright license
 * fix ATR size comment
 * fix whitespace in struct def
 * fix DPRINTF prefix
 * line width fix

ccid-card-passthru: force chardev user wakeup by sending Init

The problem: how to wakeup the user of the smartcard when the smartcard
device is initialized?

Long term solution: have a callback interface. This was done via
the deprecated so called chardev ioctl interface.

Short term solution: do a write. Specifically we write an Init message.
And we change the client to send it's own Init message regardless of
receiving this one. Additional Init messages will be regarded as
acceptable, the first one received after connection establishment is
the determining one wrt capabilities.

13 years agointroduce libcacard/vscard_common.h
Alon Levy [Wed, 2 Feb 2011 19:48:04 +0000 (21:48 +0200)]
introduce libcacard/vscard_common.h

---

Signed-off-by: Alon Levy <alevy@redhat.com>
v20->v21 changes: (Jes Sorensen review)
 * license set to 2+
 * long comment fixes, remove empty line at eof.
 * add reference to COPYING

v19->v20 changes:
 * checkpatch.pl

v15->v16 changes:

Protocol change:
 * VSCMsgInit capabilities and magic
 * removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
 * adaded Flush and FlushComplete, remove Reconnect.
 * define VSCARD_MAGIC
 * added error code VSC_SUCCESS.

Fixes:
 * update VSCMsgInit comment
 * fix message type enum
 * remove underscore from wrapping define
 * update copyright
 * updated comments.
 * Header comment updated
 * remove C++ style comment
 * fix comment for VSCMsgError
 * give names to enums in typedefs

13 years agousb-ccid: add CCID bus
Alon Levy [Sun, 17 Oct 2010 09:40:07 +0000 (11:40 +0200)]
usb-ccid: add CCID bus

A CCID device is a smart card reader. It is a USB device, defined at [1].
This patch introduces the usb-ccid device that is a ccid bus. Next patches will
introduce two card types to use it, a passthru card and an emulated card.

 [1] http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.

Signed-off-by: Alon Levy <alevy@redhat.com>
---

changes from v20->v21: (Jes Sorenson review)
 * cosmetic changes - fix multi line comments.
 * reorder fields in USBCCIDState
 * add reference to COPYING
 * add --enable-smartcard and --disable-smartcard here (moved
 from last patch)

changes from v19->v20:
 * checkpatch.pl

changes from v18->v19:
 * merged: ccid.h: add copyright, fix define and remove non C89 comments
 * add qdev.desc

changes from v15->v16:

Behavioral changes:
 * fix abort on client answer after card remove
 * enable migration
 * remove side affect code from asserts
 * return consistent self-powered state
 * mask out reserved bits in ccid_set_parameters
 * add missing abRFU in SetParameters (no affect on linux guest)

whitefixes / comments / consts defines:
 * remove stale comment
 * remove ccid_print_pending_answers if no DEBUG_CCID
 * replace printf's with DPRINTF, remove DEBUG_CCID, add verbosity defines
 * use error_report
 * update copyright (most of the code is not original)
 * reword known bug comment
 * add missing closing quote in comment
 * add missing whitespace on one line
 * s/CCID_SetParameter/CCID_SetParameters/
 * add comments
 * use define for max packet size

Comment for "return consistent self-powered state":

the Configuration Descriptor bmAttributes claims we are self powered,
but we were returning not self powered to USB_REQ_GET_STATUS control message.

In practice, this message is not sent by a linux 2.6.35.10-74.fc14.x86_64
guest (not tested on other guests), unless you issue lsusb -v as root (for
example).

13 years agoqemu-thread.h: include inttypes.h
Alon Levy [Mon, 14 Mar 2011 22:18:02 +0000 (00:18 +0200)]
qemu-thread.h: include inttypes.h

qemu-thread.h relies on uint64_t being defined, but doesn't include
inttypes.h explicitly. This makes it easier to use it from vscclient (part
of libcacard).

13 years agotrace: move trace objects from Makefile to Makefile.objs
Alon Levy [Wed, 16 Mar 2011 15:30:21 +0000 (17:30 +0200)]
trace: move trace objects from Makefile to Makefile.objs

13 years agonet: Improve the warnings for dubious command line option combinations
Peter Maydell [Tue, 22 Mar 2011 18:39:40 +0000 (18:39 +0000)]
net: Improve the warnings for dubious command line option combinations

Improve the warnings we give if the user specified a combination of -net
options which don't make much sense:
 * Don't warn about anything if the config is the implicit default
   "-net user -net nic" rather than one specified by the user (this will
   only kick in for boards with no NIC or if CONFIG_SLIRP is not set)
 * Diagnose the case where the user asked for NICs which the board
   didn't instantiate (for example where the user asked for two NICs
   but the board only supports one)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agohw/versatilepb, realview: Fix condition for instantiation of onboard NIC
Peter Maydell [Tue, 22 Mar 2011 18:21:58 +0000 (18:21 +0000)]
hw/versatilepb, realview: Fix condition for instantiation of onboard NIC

Correct the condition determining whether we instantiate the onboard
NIC or a PCI card NIC on VersatilePB and Realview boards. This was broken
in two ways:
 (1) if the user asked for two default NICs ("-net nic -net nic") we would
crash trying to strcmp() a NULL pointer
 (2) if the user asked for two NICs explicitly of the same model as the
onboard NIC (eg "-net nic,model=smc91c111 -net nic,model=smc91c111")
we would try to instantiate two onboard NICs at the same address.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agopcnet: Fix sign extension: make ipxe work with >2G RAM
Michael Brown [Tue, 15 Mar 2011 16:47:22 +0000 (10:47 -0600)]
pcnet: Fix sign extension: make ipxe work with >2G RAM

The problem is with definitions in hw/pcnet.c such as:

  #define CSR_CRDA(S)      ((S)->csr[28] | ((S)->csr[29] << 16))

"(S)->csr[29]" is a uint16_t, but "(S)->csr[29] << 16" gets promoted to
int, so the overall CSR_CRDA(s) is a (signed) int rather than a uint32_t.

This then gets assigned to a uint64_t using

  target_phys_addr_t crda = CSR_CRDA(s);

so when (S)->csr[29] has the high bit set, we end up with
crda=0xffffffffxxxxxxxx.

From: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Don't leak TCG temp for UNDEFs in Neon load/store space
Peter Maydell [Tue, 15 Mar 2011 16:26:52 +0000 (16:26 +0000)]
target-arm: Don't leak TCG temp for UNDEFs in Neon load/store space

Move the allocation and freeing of the TCG temp used for the address for
Neon load/store instructions so that we don't allocate the temporary
until we've done enough decoding to know that the instruction is not
an UNDEF pattern; this avoids leaking the TCG temp in these cases.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Fix VLD of single element to all lanes
Peter Maydell [Tue, 15 Mar 2011 16:26:51 +0000 (16:26 +0000)]
target-arm: Fix VLD of single element to all lanes

Fix several bugs in VLD of single element to all lanes:

The "single element to all lanes" form of VLD1 differs from those for
VLD2, VLD3 and VLD4 in that bit 5 indicates whether the loaded element
should be written to one or two Dregs (rather than being a register
stride). Handle this by special-casing VLD1 rather than trying to
have one loop which deals with both VLD1 and 2/3/4.

Handle VLD4.32 with 16 byte alignment specified, rather than UNDEFfing.

UNDEF for the invalid size and alignment combinations.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoFix net_check_clients warnings: make it per vlan.
Tristan Gingold [Tue, 15 Mar 2011 13:20:54 +0000 (14:20 +0100)]
Fix net_check_clients warnings: make it per vlan.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agovnc: added missing name->keysym pairs for Polish national characters
Leszek Grzegorek [Mon, 14 Mar 2011 09:30:08 +0000 (10:30 +0100)]
vnc: added missing name->keysym pairs for Polish national characters

There are no { name, keysym } values in name2keysym[] array for Polish
national characters so "-k pl" option has no effect.

Signed-off-by: Leszek Grzegorek <leszek.grzegorek@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoget rid of private bitmap functions in block/sheepdog.c, use generic ones
Michael Tokarev [Thu, 10 Mar 2011 14:03:41 +0000 (17:03 +0300)]
get rid of private bitmap functions in block/sheepdog.c, use generic ones

qemu now has generic bitmap functions,
so don't redefine them in sheepdog.c,
use common header instead.  A small cleanup.

Here's only one function which is actually
used in sheepdog and gets replaced with
a generic one (simplified):

- static inline int test_bit(int nr, const volatile unsigned long *addr)
+ static inline int test_bit(int nr, const unsigned long *addr)
 {
-  return ((1UL << (nr % BITS_PER_LONG))
            & ((unsigned long*)addr)[nr / BITS_PER_LONG])) != 0;
+  return 1UL & (addr[nr / BITS_PER_LONG] >> (nr & (BITS_PER_LONG-1)));
 }

The body is equivalent, but the argument is not: there's
"volatile" in there.  Why it is used for - I'm not sure.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Acked-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agolsi53c895a: add support for ABORT messages
Bernhard Kohl [Mon, 6 Sep 2010 04:42:54 +0000 (04:42 +0000)]
lsi53c895a: add support for ABORT messages

If these messages are not handled correctly the guest driver may hang.

Always mandatory:
- ABORT
- BUS DEVICE RESET

Mandatory if tagged queuing is implemented (which disks usually do):
- ABORT TAG
- CLEAR QUEUE

Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agofix build errors when we enable acpi_piix4 debug
Wen Congyang [Mon, 28 Feb 2011 02:22:33 +0000 (10:22 +0800)]
fix build errors when we enable acpi_piix4 debug

I enable acpi_piix4 debug, and got the following build errors:
# make
  CC    libhw64/acpi_piix4.o
cc1: warnings being treated as errors
/home/wency/source/qemu/hw/acpi_piix4.c: In function â€˜pm_ioport_write’:
/home/wency/source/qemu/hw/acpi_piix4.c:193: error: format â€˜%04x’ expects type â€˜unsigned int’, but argument 2 has type â€˜uint64_t’
/home/wency/source/qemu/hw/acpi_piix4.c:193: error: format â€˜%04x’ expects type â€˜unsigned int’, but argument 3 has type â€˜uint64_t’
/home/wency/source/qemu/hw/acpi_piix4.c: In function â€˜pm_ioport_read’:
/home/wency/source/qemu/hw/acpi_piix4.c:219: error: format â€˜%04x’ expects type â€˜unsigned int’, but argument 2 has type â€˜uint64_t’
make[1]: *** [acpi_piix4.o] Error 1
make: *** [subdir-libhw64] Error 2

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoui/sdl: Load optional QEMU icon
Stefan Weil [Wed, 16 Feb 2011 20:15:40 +0000 (21:15 +0100)]
ui/sdl: Load optional QEMU icon

Load an optional QEMU icon file. If there is no icon file named
qemu.bmp in QEMU's default search path, QEMU will run with
the usual system default icon.

A matching icon file  will be loaded and used by X Windows managers
or MS Windows while a QEMU instance is running.

SDL requires icon files in 32x32x4 bmp format.

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 agopc-bios/spapr-rtas.bin: remove executable flag
Aurelien Jarno [Fri, 1 Apr 2011 18:04:24 +0000 (20:04 +0200)]
pc-bios/spapr-rtas.bin: remove executable flag

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoAdd SLOF-based partition firmware for pSeries machine, allowing more boot options
David Gibson [Fri, 1 Apr 2011 04:15:34 +0000 (15:15 +1100)]
Add SLOF-based partition firmware for pSeries machine, allowing more boot options

Currently, the emulated pSeries machine requires the use of the
-kernel parameter in order to explicitly load a guest kernel.  This
means booting from the virtual disk, cdrom or network is not possible.

This patch addresses this limitation by inserting a within-partition
firmware image (derived from the "SLOF" free Open Firmware project).
If -kernel is not specified, qemu will now load the SLOF image, which
has access to the qemu boot device list through the device tree, and
can boot from any of the usual virtual devices.

In order to support the new firmware, an extension to the emulated
machine/hypervisor is necessary.  Unlike Linux, which expects
multi-CPU entry to be handled kexec() style, the SLOF firmware expects
only one CPU to be active at entry, and to use a hypervisor RTAS
method to enable the other CPUs one by one.

This patch also implements this 'start-cpu' method, so that SLOF can
start the secondary CPUs and marshal them into the kexec() holding
pattern ready for entry into the guest OS.  Linux should, and in the
future might directly use the start-cpu method to enable initially
disabled CPUs, but for now it does require kexec() entry.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement PAPR VPA functions for pSeries shared processor partitions
David Gibson [Fri, 1 Apr 2011 04:15:33 +0000 (15:15 +1100)]
Implement PAPR VPA functions for pSeries shared processor partitions

Shared-processor partitions are those where a CPU is time-sliced between
partitions, rather than being permanently dedicated to a single
partition.  qemu emulated partitions, since they are just scheduled with
the qemu user process, behave mostly like shared processor partitions.

In order to better support shared processor partitions (splpar), PAPR
defines the "VPA" (Virtual Processor Area), a shared memory communication
channel between the hypervisor and partitions.  There are also two
additional shared memory communication areas for specialized purposes
associated with the VPA.

A VPA is not essential for operating an splpar, though it can be necessary
for obtaining accurate performance measurements in the presence of
runtime partition switching.

Most importantly, however, the VPA is a prerequisite for PAPR's H_CEDE,
hypercall, which allows a partition OS to give up it's shared processor
timeslices to other partitions when idle.

This patch implements the VPA and H_CEDE hypercalls in qemu.  We don't
implement any of the more advanced statistics which can be communicated
through the VPA.  However, this is enough to make normal pSeries kernels
do an effective power-save idle on an emulated pSeries, significantly
reducing the host load of a qemu emulated pSeries running an idle guest OS.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoAdd a PAPR TCE-bypass mechanism for the pSeries machine
Ben Herrenschmidt [Fri, 1 Apr 2011 04:15:32 +0000 (15:15 +1100)]
Add a PAPR TCE-bypass mechanism for the pSeries machine

Usually, PAPR virtual IO devices use a virtual IOMMU mechanism, TCEs,
to mediate all DMA transfers.  While this is necessary for some sorts of
operation, it can be complex to program and slow for others.

This patch implements a mechanism for bypassing TCE translation, treating
"IO" addresses as plain (guest) physical memory addresses.  This has two
main uses:
 * Simple, but 64-bit aware programs like firmwares can use the VIO devices
without the complexity of TCE setup.
 * The guest OS can optionally use the TCE bypass to improve performance in
suitable situations.

The mechanism used is a per-device flag which disables TCE translation.
The flag is toggled with some (hypervisor-implemented) RTAS methods.

Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement PAPR virtual SCSI interface (ibmvscsi)
Ben Herrenschmidt [Fri, 1 Apr 2011 04:15:31 +0000 (15:15 +1100)]
Implement PAPR virtual SCSI interface (ibmvscsi)

This patch implements the infrastructure and hypercalls necessary for
the PAPR specified Virtual SCSI interface.  This is the normal method
for providing (virtual) disks to PAPR partitions.

Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement PAPR CRQ hypercalls
Ben Herrenschmidt [Fri, 1 Apr 2011 04:15:30 +0000 (15:15 +1100)]
Implement PAPR CRQ hypercalls

This patch implements the infrastructure and hypercalls necessary for the
PAPR specified CRQ (Command Request Queue) mechanism.  This general
request queueing system is used by many of the PAPR virtual IO devices,
including the virtual scsi adapter.

Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement sPAPR Virtual LAN (ibmveth)
David Gibson [Fri, 1 Apr 2011 04:15:29 +0000 (15:15 +1100)]
Implement sPAPR Virtual LAN (ibmveth)

This patch implements the PAPR specified Inter Virtual Machine Logical
LAN; that is the virtual hardware used by the Linux ibmveth driver.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement TCE translation for sPAPR VIO
David Gibson [Fri, 1 Apr 2011 04:15:28 +0000 (15:15 +1100)]
Implement TCE translation for sPAPR VIO

This patch implements the necessary infrastructure and hypercalls for
sPAPR's TCE (Translation Control Entry) IOMMU mechanism.  This is necessary
for all virtual IO devices which do DMA (i.e. nearly all of them).

Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoAdd (virtual) interrupt to PAPR virtual tty device
David Gibson [Fri, 1 Apr 2011 04:15:27 +0000 (15:15 +1100)]
Add (virtual) interrupt to PAPR virtual tty device

Now that we have implemented the PAPR "xics" virtualized interrupt
controller, we can add interrupts in PAPR VIO devices.  This patch adds
interrupt support to the PAPR virtual tty/console device.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoAdd PAPR H_VIO_SIGNAL hypercall and infrastructure for VIO interrupts
David Gibson [Fri, 1 Apr 2011 04:15:26 +0000 (15:15 +1100)]
Add PAPR H_VIO_SIGNAL hypercall and infrastructure for VIO interrupts

This patch adds infrastructure to support interrupts from PAPR virtual IO
devices.  This includes correctly advertising those interrupts in the
device tree, and implementing the H_VIO_SIGNAL hypercall, used to
enable and disable individual device interrupts.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement the PAPR (pSeries) virtualized interrupt controller (xics)
David Gibson [Fri, 1 Apr 2011 04:15:25 +0000 (15:15 +1100)]
Implement the PAPR (pSeries) virtualized interrupt controller (xics)

PAPR defines an interrupt control architecture which is logically divided
into ICS (Interrupt Control Presentation, each unit is responsible for
presenting interrupts to a particular "interrupt server", i.e. CPU) and
ICS (Interrupt Control Source, each unit responsible for one or more
hardware interrupts as numbered globally across the system).  All PAPR
virtual IO devices expect to deliver interrupts via this mechanism.  In
Linux, this interrupt controller system is handled by the "xics" driver.

On pSeries systems, access to the interrupt controller is virtualized via
hypercalls and RTAS methods.  However, the virtualized interface is very
similar to the underlying interrupt controller hardware, and similar PICs
exist un-virtualized in some other systems.

This patch implements both the ICP and ICS sides of the PAPR interrupt
controller.  For now, only the hypercall virtualized interface is provided,
however it would be relatively straightforward to graft an emulated
register interface onto the underlying interrupt logic if we want to add
a machine with a hardware ICS/ICP system in the future.

There are some limitations in this implementation: it is assumed for now
that only one instance of the ICS exists, although a full xics system can
have several, each responsible for a different group of hardware irqs.
ICP/ICS can handle both level-sensitve (LSI) and message signalled (MSI)
interrupt inputs.  For now, this implementation supports only MSI
interrupts, since that is used by PAPR virtual IO devices.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement assorted pSeries hcalls and RTAS methods
David Gibson [Fri, 1 Apr 2011 04:15:24 +0000 (15:15 +1100)]
Implement assorted pSeries hcalls and RTAS methods

This patch adds several small utility hypercalls and RTAS methods to
the pSeries platform emulation.  Specifically:

* 'display-character' rtas call

This just prints a character to the console, it's occasionally used
for early debug of the OS.  The support includes a hack to make this
RTAS call respond on the normal token value present on real hardware,
since some early debugging tools just assume this value without
checking the device tree.

* 'get-time-of-day' rtas call

This one just takes the host real time, converts to the PAPR described
format and returns it to the guest.

* 'power-off' rtas call

This one shuts down the emulated system.

* H_DABR hypercall

On pSeries, the DABR debug register is usually a hypervisor resource
and virtualized through this hypercall.  If the hypercall is not
present, Linux will under some circumstances attempt to manipulate the
DABR directly which will fail on this emulated machine.

This stub implementation is enough to stop that behaviour, although it
doesn't actually implement the requested DABR operations as yet.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement hcall based RTAS for pSeries machines
David Gibson [Fri, 1 Apr 2011 04:15:23 +0000 (15:15 +1100)]
Implement hcall based RTAS for pSeries machines

On pSeries machines, operating systems can instantiate "RTAS" (Run-Time
Abstraction Services), a runtime component of the firmware which implements
a number of low-level, infrequently used operations.  On logical partitions
under a hypervisor, many of the RTAS functions require hypervisor
privilege.  For simplicity, therefore, hypervisor systems typically
implement the in-partition RTAS as just a tiny wrapper around a hypercall
which actually implements the various RTAS functions.

This patch implements such a hypercall based RTAS for our emulated pSeries
machine.  A tiny in-partition "firmware" calls a new hypercall, which
looks up available RTAS services in a table.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoVirtual hash page table handling on pSeries machine
David Gibson [Fri, 1 Apr 2011 04:15:22 +0000 (15:15 +1100)]
Virtual hash page table handling on pSeries machine

On pSeries logical partitions, excepting the old POWER4-style full system
partitions, the guest does not have direct access to the hardware page
table.  Instead, the pagetable exists in hypervisor memory, and the guest
must manipulate it with hypercalls.

However, our current pSeries emulation more closely resembles the old
style where the guest must set up and handle the pagetables itself.  This
patch converts it to act like a modern partition.

This involves two things: first, the hash translation path is modified to
permit the has table to be stored externally to the emulated machine's
RAM.  The pSeries machine init code configures the CPUs to use this mode.

Secondly, we emulate the PAPR hypercalls for manipulating the external
hashed page table.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement the bus structure for PAPR virtual IO
David Gibson [Fri, 1 Apr 2011 04:15:21 +0000 (15:15 +1100)]
Implement the bus structure for PAPR virtual IO

This extends the "pseries" (PAPR) machine to include a virtual IO bus
supporting the PAPR defined hypercall based virtual IO mechanisms.

So far only one VIO device is provided, the vty / vterm, providing
a full console (polled only, for now).

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoStart implementing pSeries logical partition machine
David Gibson [Fri, 1 Apr 2011 04:15:20 +0000 (15:15 +1100)]
Start implementing pSeries logical partition machine

This patch adds a "pseries" machine to qemu.  This aims to emulate a
logical partition on an IBM pSeries machine, compliant to the
"PowerPC Architecture Platform Requirements" (PAPR) document.

This initial version is quite limited, it implements a basic machine
and PAPR hypercall emulation.  So far only one hypercall is present -
H_PUT_TERM_CHAR - so that a (write-only) console is available.

Multiple CPUs are permitted, with SMP entry handled kexec() style.

The machine so far more resembles an old POWER4 style "full system
partition" rather than a modern LPAR, in that the guest manages the
page tables directly, rather than via hypercalls.

The machine requires qemu to be configured with --enable-fdt.  The
machine can (so far) only be booted with -kernel - i.e. no partition
firmware is provided.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoAdd POWER7 support for ppc
David Gibson [Fri, 1 Apr 2011 04:15:19 +0000 (15:15 +1100)]
Add POWER7 support for ppc

This adds emulation support for the recent POWER7 cpu to qemu.  It's far
from perfect - it's missing a number of POWER7 features so far, including
any support for VSX or decimal floating point instructions.  However, it's
close enough to boot a kernel with the POWER7 PVR.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoSupport 1T segments on ppc
David Gibson [Fri, 1 Apr 2011 04:15:18 +0000 (15:15 +1100)]
Support 1T segments on ppc

Traditionally, the "segments" used for the two-stage translation used on
powerpc MMUs were 256MB in size.  This was the only option on all hash
page table based 32-bit powerpc cpus, and on the earlier 64-bit hash page
table based cpus.  However, newer 64-bit cpus also permit 1TB segments

This patch adds support for 1TB segment translation to the qemu code.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoBetter factor the ppc hash translation path
David Gibson [Fri, 1 Apr 2011 04:15:17 +0000 (15:15 +1100)]
Better factor the ppc hash translation path

Currently the path handling hash page table translation in get_segment()
has a mix of common and 32 or 64 bit specific code.  However the
division is not done terribly well which results in a lot of messy code
flipping between common and divided paths.

This patch improves the organization, consolidating several divided paths
into one.  This in turn allows simplification of some code in
get_segment(), removing a number of ugly interim variables.

This new factorization will also make it easier to add support for the 1T
segments added in newer CPUs.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoUse "hash" more consistently in ppc mmu code
David Gibson [Fri, 1 Apr 2011 04:15:16 +0000 (15:15 +1100)]
Use "hash" more consistently in ppc mmu code

Currently, get_segment() has a variable called hash.  However it doesn't
(quite) get the hash value for the ppc hashed page table.  Instead it
gets the hash shifted - effectively the offset of the hash bucket within
the hash page table.

As well, as being different to the normal use of plain "hash" in the
architecture documentation, this usage necessitates some awkward 32/64
dependent masks and shifts which clutter up the path in get_segment().

This patch alters the code to use raw hash values through get_segment()
including storing raw hashes instead of pte group offsets in the ctx
structure.  This cleans up the path noticeably.

This does necessitate 32/64 dependent shifts when the hash values are
taken out of the ctx structure and used, but those paths already have
32/64 bit variants so this is less awkward than it was in get_segment().

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoParse SDR1 on mtspr instead of at translate time
David Gibson [Fri, 1 Apr 2011 04:15:15 +0000 (15:15 +1100)]
Parse SDR1 on mtspr instead of at translate time

On ppc machines with hash table MMUs, the special purpose register SDR1
contains both the base address of the encoded size (hashed) page tables.

At present, we interpret the SDR1 value within the address translation
path.  But because the encodings of the size for 32-bit and 64-bit are
different this makes for a confusing branch on the MMU type with a bunch
of curly shifts and masks in the middle of the translate path.

This patch cleans things up by moving the interpretation on SDR1 into the
helper function handling the write to the register.  This leaves a simple
pre-sanitized base address and mask for the hash table in the CPUState
structure which is easier to work with in the translation path.

This makes the translation path more readable.  It addresses the FIXME
comment currently in the mtsdr1 helper, by validating the SDR1 value during
interpretation.  Finally it opens the way for emulating a pSeries-style
partition where the hash table used for translation is not mapped into
the guests's RAM.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoClean up slb_lookup() function
David Gibson [Fri, 1 Apr 2011 04:15:14 +0000 (15:15 +1100)]
Clean up slb_lookup() function

The slb_lookup() function, used in the ppc translation path returns a
number of slb entry fields in reference parameters.  However, only one
of the two callers of slb_lookup() actually wants this information.

This patch, therefore, makes slb_lookup() return a simple pointer to the
located SLB entry (or NULL), and the caller which needs the fields can
extract them itself.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoCorrect ppc popcntb logic, implement popcntw and popcntd
David Gibson [Fri, 1 Apr 2011 04:15:13 +0000 (15:15 +1100)]
Correct ppc popcntb logic, implement popcntw and popcntd

qemu already includes support for the popcntb instruction introduced
in POWER5 (although it doesn't actually allow you to choose POWER5).

However, the logic is slightly incorrect: it will generate results
truncated to 32-bits when the CPU is in 32-bit mode.  This is not
normal for powerpc - generally arithmetic instructions on a 64-bit
powerpc cpu will generate full 64 bit results, it's just that only the
low 32 bits will be significant for condition codes.

This patch corrects this nit, which actually simplifies the code slightly.

In addition, this patch implements the popcntw and popcntd
instructions added in POWER7, in preparation for allowing POWER7 as an
emulated CPU.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement missing parts of the logic for the POWER PURR
David Gibson [Fri, 1 Apr 2011 04:15:12 +0000 (15:15 +1100)]
Implement missing parts of the logic for the POWER PURR

The PURR (Processor Utilization Resource Register) is a register found
on recent POWER CPUs.  The guts of implementing it at least enough to
get by are already present in qemu, however some of the helper
functions needed to actually wire it up are missing.

This patch adds the necessary glue, so that the PURR can be wired up
when we implement newer POWER CPU targets which include it.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoImplement PowerPC slbmfee and slbmfev instructions
David Gibson [Fri, 1 Apr 2011 04:15:11 +0000 (15:15 +1100)]
Implement PowerPC slbmfee and slbmfev instructions

For a 64-bit PowerPC target, qemu correctly implements translation
through the segment lookaside buffer.  Likewise it supports the
slbmte instruction which is used to load entries into the SLB.

However, it does not emulate the slbmfee and slbmfev instructions
which read SLB entries back into registers.  Because these are
only occasionally used in guests (mostly for debugging) we get
away with it.

However, given the recent SLB cleanups, it becomes quite easy to
implement these, and thereby allow, amongst other things, a guest
Linux to use xmon's command to dump the SLB.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoAdd a hook to allow hypercalls to be emulated on PowerPC
David Gibson [Fri, 1 Apr 2011 04:15:10 +0000 (15:15 +1100)]
Add a hook to allow hypercalls to be emulated on PowerPC

PowerPC and POWER chips since the POWER4 and 970 have a special
hypervisor mode, and a corresponding form of the system call
instruction which traps to the hypervisor.

qemu currently has stub implementations of hypervisor mode.  That
is, the outline is there to allow qemu to run a PowerPC hypervisor
under emulation.  There are a number of details missing so this
won't actually work at present, but the idea is there.

What there is no provision at all, is for qemu to instead emulate
the hypervisor itself.  That is to have hypercalls trap into qemu
and their result be emulated from qemu, rather than running
hypervisor code within the emulated system.

Hypervisor hardware aware KVM implementations are in the works and
it would  be useful for debugging and development to also allow
full emulation of the same para-virtualized guests as such a KVM.

Therefore, this patch adds a hook which will allow a machine to
set up emulation of hypervisor calls.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoAllow qemu_devtree_setprop() to take arbitrary values
David Gibson [Fri, 1 Apr 2011 04:15:09 +0000 (15:15 +1100)]
Allow qemu_devtree_setprop() to take arbitrary values

Currently qemu_devtree_setprop() expects the new property value to be
given as a uint32_t *.  While property values consisting of u32s are
common, in general they can have any bytestring value.

Therefore, this patch alters the function to take a void * instead,
allowing callers to easily give anything as the property value.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoClean up PowerPC SLB handling code
David Gibson [Fri, 1 Apr 2011 04:15:08 +0000 (15:15 +1100)]
Clean up PowerPC SLB handling code

Currently the SLB information when emulating a PowerPC 970 is
storeed in a structure with the unhelpfully named fields 'tmp'
and 'tmp64'.  While the layout in these fields does match the
description of the SLB in the architecture document, it is not
convenient either for looking up the SLB, or for emulating the
slbmte instruction.

This patch, therefore, reorganizes the SLB entry structure to be
divided in the the "ESID related" and "VSID related" fields as
they are divided in instructions accessing the SLB.

In addition to making the code smaller and more readable, this will
make it easier to implement for the 1TB segments used in more
recent PowerPC chips.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agotarget-ppc: ext32u instead of andi with constant
Aurelien Jarno [Tue, 22 Mar 2011 06:41:29 +0000 (07:41 +0100)]
target-ppc: ext32u instead of andi with constant

Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agolm32: use lookup table for opcodes
Michael Walle [Mon, 7 Mar 2011 22:01:04 +0000 (23:01 +0100)]
lm32: use lookup table for opcodes

Instead of a for loop use a faster lookup table.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agolm32: rename raise opcode to scall
Michael Walle [Mon, 7 Mar 2011 22:00:13 +0000 (23:00 +0100)]
lm32: rename raise opcode to scall

To be consistent with the new reference manual.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13 years agoadd a service to reap zombies, use it in SLIRP
Paolo Bonzini [Wed, 9 Mar 2011 17:21:10 +0000 (18:21 +0100)]
add a service to reap zombies, use it in SLIRP

SLIRP -smb support wants to fork a process and forget about reaping it.
To please it, add a generic service to register a process id and let
QEMU reap it.  In the future it could be enhanced to pass a status,
but this would be unused.

With this in place, the SIGCHLD signal handler would not stomp on pclose
anymore.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoextract I/O handler lists to iohandler.c
Paolo Bonzini [Wed, 9 Mar 2011 17:21:09 +0000 (18:21 +0100)]
extract I/O handler lists to iohandler.c

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovhost: fix dirty page handling
Michael S. Tsirkin [Wed, 16 Mar 2011 10:09:09 +0000 (12:09 +0200)]
vhost: fix dirty page handling

vhost was passing a physical address to cpu_physical_memory_set_dirty,
which is wrong: we need to translate to ram address first.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Note: this lead to crashes during migration, so the patch
is needed on the stable branch too.

13 years agovirtio-serial: don't crash on invalid input
Michael S. Tsirkin [Tue, 22 Mar 2011 16:32:50 +0000 (18:32 +0200)]
virtio-serial: don't crash on invalid input

Fix crash on invalid input in virtio-serial.
Discovered by code review, untested.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agoe1000: check buffer availability
Michael S. Tsirkin [Sun, 27 Mar 2011 11:37:35 +0000 (13:37 +0200)]
e1000: check buffer availability

Reduce spurious packet drops on RX ring empty
by verifying that we have at least 1 buffer
ahead of the time.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agovirtio-pci: fix bus master work around on load
Michael S. Tsirkin [Sat, 19 Mar 2011 17:28:19 +0000 (19:28 +0200)]
virtio-pci: fix bus master work around on load

Commit c81131db15dd1844d0db1d51f3cd7a105cfd2cf3
detects old guests by comparing virtio and
PCI status. It attempts to do this on load,
as well, but load_config callback in a binding
is invoked too early and so the virtio status
isn't set yet.

We could add yet another callback to the
binding, to invoke after load, but it
seems easier to reuse the existing vmstate
callback.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
13 years agopci: use uint8_t for devfn_min
Isaku Yamahata [Thu, 27 Jan 2011 06:56:39 +0000 (15:56 +0900)]
pci: use uint8_t for devfn_min

use uint8_t for devfn_min instead of int.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agopci: use PCI_DEVFN in pci_get_bus_devfn()
Isaku Yamahata [Thu, 27 Jan 2011 06:56:38 +0000 (15:56 +0900)]
pci: use PCI_DEVFN in pci_get_bus_devfn()

Replace hardcoded logic by a common macro.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agopci: use devfn for pci_find_device() instead of (slot, fn) pair
Isaku Yamahata [Thu, 27 Jan 2011 06:56:36 +0000 (15:56 +0900)]
pci: use devfn for pci_find_device() instead of (slot, fn) pair

(slot, fn) pair is somewhat confusing because of ARI.
So use devfn for pci_find_device() instead of (slot, fn).

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agopci: replace the magic, 256, for the maximum of devfn
Isaku Yamahata [Thu, 27 Jan 2011 06:56:35 +0000 (15:56 +0900)]
pci: replace the magic, 256, for the maximum of devfn

Introduce symbol PCI_SLOT_MAX for the # of slots,
and replace the magic, 256.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
13 years agoreport that QEMU process was killed by a signal
Gleb Natapov [Tue, 15 Mar 2011 11:56:04 +0000 (13:56 +0200)]
report that QEMU process was killed by a signal

Currently when rogue script kills QEMU process (using TERM/INT/HUP
signal) it looks indistinguishable from system shutdown. Lets report
that QEMU was killed and leave some clues about the killer identity.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agortl8139: add vlan tag insertion
Benjamin Poirier [Tue, 22 Mar 2011 23:11:23 +0000 (19:11 -0400)]
rtl8139: add vlan tag insertion

Add support to the emulated hardware to insert vlan tags in packets
going from the guest to the network.

Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Cc: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agortl8139: add vlan tag extraction
Benjamin Poirier [Tue, 22 Mar 2011 23:11:22 +0000 (19:11 -0400)]
rtl8139: add vlan tag extraction

Add support to the emulated hardware to extract vlan tags in packets
going from the network to the guest.

Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Cc: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
--

AFAIK, extraction is optional to get vlans working. The driver
requests rx detagging but should not assume that it was done. Under
Linux, the mac layer will catch the vlan ethertype. I only added this
part for completeness (to emulate the hardware more truthfully...)
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agortl8139: cleanup FCS calculation
Benjamin Poirier [Tue, 22 Mar 2011 23:11:21 +0000 (19:11 -0400)]
rtl8139: cleanup FCS calculation

clean out ifdef's around ethernet checksum calculation

Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Acked-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agosevere memory leak caused by broken palette_destroy() function
Ulrich Obergfell [Fri, 25 Mar 2011 08:45:54 +0000 (04:45 -0400)]
severe memory leak caused by broken palette_destroy() function

The following commit breaks the code of the function palette_destroy().

http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=e31e3694afef58ba191cbcc6875ec243e5971268

The broken code causes a severe memory leak of 'VncPalette' structures
because it never frees anything:

     70 void palette_destroy(VncPalette *palette)
     71 {
     72     if (palette == NULL) {
     73         qemu_free(palette);
     74     }
     75 }

Version 2 of the patch calls qemu_free() unconditionally.

Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovl.c: Fix compilation failure if CONFIG_SDL isn't defined
Peter Maydell [Wed, 23 Mar 2011 03:40:57 +0000 (03:40 +0000)]
vl.c: Fix compilation failure if CONFIG_SDL isn't defined

Fix a compilation failure if CONFIG_SDL isn't defined (gcc complained
that the label 'invalid_display' wasn't used).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMerge remote branch 'amit/for-anthony' into staging
Anthony Liguori [Thu, 24 Mar 2011 13:11:58 +0000 (08:11 -0500)]
Merge remote branch 'amit/for-anthony' into staging

13 years agotcg/arm: Support host code being compiled for Thumb
Peter Maydell [Wed, 16 Mar 2011 15:21:31 +0000 (15:21 +0000)]
tcg/arm: Support host code being compiled for Thumb

Although the TCG generated code is always in ARM mode, it is possible
that the host code was compiled by gcc in Thumb mode (this is often the
default for Linux distributions targeting ARM v7 only). Handle this
by using BLX imm when doing a call from ARM into Thumb mode.
Since BLX imm is not a conditionalisable instruction, we make
tcg_out_call() no longer take a condition code; we were only ever
using it with COND_AL anyway.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoRevert "x86: Save/restore PAT MSR"
Anthony Liguori [Tue, 22 Mar 2011 12:58:52 +0000 (07:58 -0500)]
Revert "x86: Save/restore PAT MSR"

This reverts commit c995b495b9d6e60ab1e390bd398a22425d0b3c8c.

From Jan Kiszka:

 Ouch, indeed. Moreover, CPU_SAVE_VERSION was not updated (likely the
 reason for the breakage). Thanks for debugging this!

 Anthony (or whoever), please revert this unneeded commit in qemu.git.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>