sdk/emulator/qemu.git
12 years agomonitor: avoid declaring unused variables
Blue Swirl [Sat, 18 Aug 2012 20:14:54 +0000 (20:14 +0000)]
monitor: avoid declaring unused variables

Some variables are only used on !win32, declare
them only when used.

This avoids a warning in mingw32 build:
  CC    i386-softmmu/monitor.o
/src/qemu/monitor.c: In function 'monitor_fdset_get_fd':
/src/qemu/monitor.c:2575: warning: unused variable 'mon_fd_flags'
/src/qemu/monitor.c:2574: warning: unused variable 'mon_fdset_fd'
/src/qemu/monitor.c:2573: warning: unused variable 'mon_fdset'

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Fix memory leak
Stefan Weil [Sat, 18 Aug 2012 20:51:29 +0000 (22:51 +0200)]
qapi: Fix memory leak

valgrind report:

==24534== 232 bytes in 2 blocks are definitely lost in loss record 1,245 of 1,601
==24534==    at 0x4824F20: malloc (vg_replace_malloc.c:236)
==24534==    by 0x293C88: malloc_and_trace (vl.c:2281)
==24534==    by 0x489AD99: ??? (in /lib/libglib-2.0.so.0.2400.1)
==24534==    by 0x489B23B: g_malloc0 (in /lib/libglib-2.0.so.0.2400.1)
==24534==    by 0x2B4EFC: opts_visitor_new (opts-visitor.c:376)
==24534==    by 0x29DEA5: net_client_init (net.c:708)
==24534==    by 0x29E6C7: net_init_client (net.c:966)
==24534==    by 0x2C2179: qemu_opts_foreach (qemu-option.c:1114)
==24534==    by 0x29E85B: net_init_clients (net.c:1008)
==24534==    by 0x296F40: main (vl.c:3463)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoUpdate OpenBIOS images
Blue Swirl [Sun, 19 Aug 2012 13:39:31 +0000 (13:39 +0000)]
Update OpenBIOS images

Update OpenBIOS images to SVN r1062. Build with GCC 4.6.0
in order to avoid boot problems introduced by GCC 4.7.[01].

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agopc: Fix RTC CMOS info on RAM for ram_size < 1MiB
Markus Armbruster [Wed, 15 Aug 2012 11:12:20 +0000 (13:12 +0200)]
pc: Fix RTC CMOS info on RAM for ram_size < 1MiB

pc_cmos_init() always claims 640KiB base memory, and ram_size - 1MiB
extended memory.  The latter can underflow to "lots of extended
memory".  Fix both, and clean up some.

Note: SeaBIOS currently requires 1MiB of RAM, and doesn't check
whether it got enough.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agovl: Round argument of -m up to multiple of 8KiB
Markus Armbruster [Wed, 15 Aug 2012 11:12:19 +0000 (13:12 +0200)]
vl: Round argument of -m up to multiple of 8KiB

Partial pages make little sense and don't work.  Ensure the RAM size
is a multiple of any possible target's page size.

Fixes

    $ qemu-system-x86_64 -nodefaults -S -vnc :0 -m 0.8
    qemu-system-x86_64: /work/armbru/qemu/exec.c:2255: register_subpage: Assertion `existing->mr->subpage || existing->mr == &io_mem_unassigned' failed.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoscsi: fix warning
Gerd Hoffmann [Mon, 13 Aug 2012 11:05:44 +0000 (13:05 +0200)]
scsi: fix warning

hw/scsi-bus.c:758: warning: ‘xfer’ may be used uninitialized in this
function

Isn't true, but older gcc versions (for example 4.1 as shipped in rhel5)
are not clever enougth to figure, so sprinkle in a default: line to make
them happy.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoAvoid asprintf() which is not available on mingw
Gerd Hoffmann [Mon, 13 Aug 2012 11:05:43 +0000 (13:05 +0200)]
Avoid asprintf() which is not available on mingw

Use g_strdup_printf() instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoUpdate version to 1.2.0-rc0
Anthony Liguori [Thu, 16 Aug 2012 18:56:34 +0000 (13:56 -0500)]
Update version to 1.2.0-rc0

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqemu-char: (Re-)connect for tcp_chr_write() unconnected writing
Lei Li [Thu, 19 Jul 2012 14:09:22 +0000 (22:09 +0800)]
qemu-char: (Re-)connect for tcp_chr_write() unconnected writing

tcp_chr_write() did not deal with writing to an unconnected
connection and return the original length of the data, it's
not right and would cause false writing. So (re-)connect it
and return 0 for this situation.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoAllow QEMUMachine to override reset sequencing
David Gibson [Tue, 7 Aug 2012 06:41:51 +0000 (16:41 +1000)]
Allow QEMUMachine to override reset sequencing

qemu_system_reset() function always performs the same basic actions on
all machines.  This includes running all the reset handler hooks,
however the order in which these will run is not always easily predictable.

This patch splits the core of qemu_system_reset() - the invocation of
the reset handlers - out into a new qemu_devices_reset() function.
qemu_system_reset() will usually call qemu_devices_reset(), but that
can be now overriden by a new reset method in the QEMUMachine
structure.

Individual machines can use this reset method, if necessary, to
perform any extra, machine specific initializations which have to
occur before or after the bulk of the reset handlers.  It's expected
that the method will call qemu_devices_reset() at some point, but if
the machine has really strange ordering requirements between devices
resets it could even override that with it's own reset sequence (with
great care, obviously).

For a specific example of when this might be needed: a number of
machines (but not PC) load images specified with -kernel or -initrd
directly into the machine RAM before booting the guest.  This mostly
works at the moment, but to make this actually safe requires that this
load occurs after peripheral devices are reset - otherwise they could
have active DMAs in progress which would clobber the in memory images.
Some machines (notably pseries) also have other entry conditions which
need to be set up as the last thing before executing in guest space -
some of this could be considered "emulated firmware" in the sense that
the actions of the firmware are emulated directly by qemu rather than
by executing a firmware image within the guest.  When the platform's
firmware to OS interface is sufficiently well specified, this saves
time both in implementing the "firmware" and executing it.

aliguori: don't unconditionally dereference current_machine

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agopseries: Instantiate USB interface when required
David Gibson [Thu, 16 Aug 2012 02:03:56 +0000 (12:03 +1000)]
pseries: Instantiate USB interface when required

The pseries machine already supports the -vga std option, creating a
graphics adapter.  However, this is not very useful without being able to
add a keyboard and mouse as well.  This patch addresses this by adding
a USB interface when requested, and automatically adding a USB keyboard
and mouse when VGA is enabled.

This is a stop gap measure to get usable graphics mode on pseries while
waiting for Li Zhang's rework of USB options to go in after 1.2.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoosdep: Fix compilation failure on BSD systems
Peter Maydell [Thu, 16 Aug 2012 11:15:18 +0000 (12:15 +0100)]
osdep: Fix compilation failure on BSD systems

Fix compilation failure on BSD systems (which don't have
O_DIRECT or O_NOATIME:
osdep.c:116: error: ‘O_DIRECT’ undeclared (first use in this function)
osdep.c:116: error: (Each undeclared identifier is reported only once
osdep.c:116: error: for each function it appears in.)
osdep.c:116: error: ‘O_NOATIME’ undeclared (first use in this function)

Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoCommand line support for seccomp with -sandbox (v8)
Eduardo Otubo [Tue, 14 Aug 2012 21:44:08 +0000 (18:44 -0300)]
Command line support for seccomp with -sandbox (v8)

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v7 -> v8
 - Parse options correctly (aliguori)

12 years agoAdding seccomp calls to vl.c (v8)
Eduardo Otubo [Tue, 14 Aug 2012 21:44:07 +0000 (18:44 -0300)]
Adding seccomp calls to vl.c (v8)

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1:
 - Full seccomp calls and data included in vl.c

v1 -> v2:
 - Full seccomp calls and data removed from vl.c and put into separate
   qemu-seccomp.[ch] file.

12 years agoAdding qemu-seccomp.[ch] (v8)
Eduardo Otubo [Tue, 14 Aug 2012 21:44:06 +0000 (18:44 -0300)]
Adding qemu-seccomp.[ch] (v8)

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1:
 - I added a syscall struct using priority levels as described in the
   libseccomp man page. The priority numbers are based to the frequency
   they appear in a sample strace from a regular qemu guest run under
   libvirt.

   Libseccomp generates linear BPF code to filter system calls, those rules
   are read one after another. The priority system places the most common
   rules first in order to reduce the overhead when processing them.

v1 -> v2:
 - Fixed some style issues
 - Removed code from vl.c and created qemu-seccomp.[ch]
 - Now using ARRAY_SIZE macro
 - Added more syscalls without priority/frequency set yet

v2 -> v3:
 - Adding copyright and license information
 - Replacing seccomp_whitelist_count just by ARRAY_SIZE
 - Adding header protection to qemu-seccomp.h
 - Moving QemuSeccompSyscall definition to qemu-seccomp.c
 - Negative return from seccomp_start is fatal now.
 - Adding open() and execve() to the whitelis

v3 -> v4:
 - Tests revealed a bigger set of syscalls.
 - seccomp_start() now has an argument to set the mode according to the
   configure option trap or kill.

v4 -> v5:
 - Tests on x86_64 required a new specific set of system calls.
 - libseccomp release 1.0.0: part of the API have changed in this last
   release, had to adapt to the new function signatures.

12 years agoAdding support for libseccomp in configure and Makefile (v8)
Eduardo Otubo [Tue, 14 Aug 2012 21:44:05 +0000 (18:44 -0300)]
Adding support for libseccomp in configure and Makefile (v8)

Adding basic options to the configure script to use libseccomp or not.
The default is set to 'no'. If the flag --enable-libseccomp is used, the
script will check for its existence using pkg-config.

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2:
 - As I removed all the code related to seccomp from vl.c, I created
   qemu-seccomp.[ch].
 - Also making the configure script to add the specific line to
   Makefile.obj in order to compile with appropriate support to seccomp.

v2 -> v3:
 - Removing the line from Makefile.obj and adding it to Makefile.objs.
 - Marking libseccomp default option to 'yes' in the configure script.

v3 -> v8:
 - fix configure probe if libseccomp isn't available (aliguori)

12 years agodma: Fix stupid typo/thinko
Benjamin Herrenschmidt [Tue, 14 Aug 2012 07:41:47 +0000 (17:41 +1000)]
dma: Fix stupid typo/thinko

Hi hard a brain fart when coding that function, it will
fail to "set" the memory beyond the first 512 bytes. This
is in turn causing guest crashes in ibmveth (spapr_llan.c
on the qemu side) due to the receive queue not being
properly initialized.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agomemory: add -machine dump-guest-core=on|off
Jason Baron [Thu, 2 Aug 2012 19:44:16 +0000 (15:44 -0400)]
memory: add -machine dump-guest-core=on|off

Add a new '[,dump-guest-core=on|off]' option to the '-machine' option. When
'dump-guest-core=off' is specified, guest memory is omitted from the core dump.
The default behavior continues to be to include guest memory when a core dump is
triggered. In my testing, this brought the core dump size down from 384MB to 6MB
on a 2GB guest.

Is anything additional required to preserve this setting for migration or
savevm? I don't believe so.

Changelog:
v3:
    Eliminate globals as per Anthony's suggestion
    set no dump from qemu_ram_remap() as well
v2:
    move the option from -m to -machine, rename option dump -> dump-guest-core

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoSupport using a different compiler for Objective-C files
Peter Maydell [Sat, 11 Aug 2012 21:34:40 +0000 (22:34 +0100)]
Support using a different compiler for Objective-C files

MacOSX 10.8 ("Mountain Lion") requires us to compile our one
Objective-C source file with clang even if the rest of QEMU
requires a real gcc, because the system headers we use make
use of Apple's "Blocks" extension to C/ObjC, and mainline
gcc doesn't support that. Since we only need to use a true
gcc for the parts of QEMU that use the fixed-register
env variable, we can simply use clang to build the ObjC
file: it will link to the gcc-built objects with no problems.

Add the necessary support for an OBJCC variable in the
makefile and configure machinery; we default to clang
if we have it, otherwise whatever CC is (since gcc
might be the Apple gcc which does support Blocks).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoconfigure: Define OS_OBJECT_USE_OBJC=0 for MacOSX builds
Peter Maydell [Sat, 11 Aug 2012 21:34:39 +0000 (22:34 +0100)]
configure: Define OS_OBJECT_USE_OBJC=0 for MacOSX builds

MacOSX 10.8 ("Mountain Lion") defaults to trying to use automated
reference counting on certain objects.  This means that the system
header files will use some Objective C syntax constructs even when
compiling pure C, which confuses mainline gcc. Suppress this by
setting OS_OBJECT_USE_OBJC=0. This avoids a compile error like this:

In file included from
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:5:0,
                 from /usr/include/os/object.h:74,
                 from /usr/include/dispatch/dispatch.h:48,
                 from /System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:56,
                 from block/raw-posix.c:35:
/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:409:1: error: stray ‘@’ in program
[with a large number of further run-on errors]

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoconfigure: Don't override user's --cpu on MacOS and Solaris
Peter Maydell [Tue, 14 Aug 2012 14:35:34 +0000 (15:35 +0100)]
configure: Don't override user's --cpu on MacOS and Solaris

Both MacOS and Solaris have special case handling for the CPU
type, because the check_define probes will return i386 even if
the hardware is 64 bit and x86_64 would be preferable. Move
these checks earlier in the configure probing so that we can
do them only if the user didn't specify a CPU with --cpu. This
fixes a bug where the user's command line argument was being
ignored.

Reviewed-by: Andreas F=E4rber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agocheck-qjson: add test for large JSON objects
Michael Roth [Wed, 15 Aug 2012 18:45:44 +0000 (13:45 -0500)]
check-qjson: add test for large JSON objects

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agojson-parser: don't replicate tokens at each level of recursion
Michael Roth [Wed, 15 Aug 2012 18:45:43 +0000 (13:45 -0500)]
json-parser: don't replicate tokens at each level of recursion

Currently, when parsing a stream of tokens we make a copy of the token
list at the beginning of each level of recursion so that we do not
modify the original list in cases where we need to fall back to an
earlier state.

In the worst case, we will only read 1 or 2 tokens off the list before
recursing again, which means an upper bound of roughly N^2 token allocations.

For a "reasonably" sized QMP request (in this a QMP representation of
cirrus_vga's device state, generated via QIDL, being passed in via
qom-set), this caused my 16GB's of memory to be exhausted before any
noticeable progress was made by the parser.

This patch works around the issue by using single copy of the token list
in the form of an indexable array so that we can save/restore state by
manipulating indices.

A subsequent commit adds a "large_dict" test case which exhibits the
same behavior as above. With this patch applied the test case successfully
completes in under a second.

Tested with valgrind, make check, and QMP.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoqlist: add qlist_size()
Michael Roth [Wed, 15 Aug 2012 18:45:42 +0000 (13:45 -0500)]
qlist: add qlist_size()

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoaudio: Make pcspk card selectable again
Jan Kiszka [Thu, 16 Aug 2012 09:01:11 +0000 (11:01 +0200)]
audio: Make pcspk card selectable again

    [ The following text is in the "ISO-8859-1" character set. ]
    [ Your display is set for the "KOI8-R" character set.  ]
    [ Some special characters may be displayed incorrectly. ]

Since we moved pcspk into hwlib, CONFIG_PCSPK is no longer defined per
target. Therefore, statically built soundhw array in arch_init.c stopped
including this card.

Work around this by re-adding this define to config-target.mak.
Long-term, a dynamic creation of this soundhw list will be necessary.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: malc <av1474@comtv.ru>
12 years agoMerge remote-tracking branch 'agraf/s390-for-upstream' into staging
Anthony Liguori [Wed, 15 Aug 2012 19:59:48 +0000 (14:59 -0500)]
Merge remote-tracking branch 'agraf/s390-for-upstream' into staging

* agraf/s390-for-upstream:
  s390: provide interface for service interrupt/introduce interrupt.c
  s390: Fix error handling and condition code of service call

12 years agoMerge remote-tracking branch 'agraf/ppc-for-upstream' into staging
Anthony Liguori [Wed, 15 Aug 2012 19:59:21 +0000 (14:59 -0500)]
Merge remote-tracking branch 'agraf/ppc-for-upstream' into staging

* agraf/ppc-for-upstream: (24 commits)
  openpic: Added BRR1 register
  pseries: Update SLOF firmware image
  pseries dma: DMA window params added to PHB and DT population changed
  pseries: Add PCI MSI/MSI-X support
  pseries: Add trace event for PCI irqs
  pseries: Export find_phb() utility function for PCI code
  pseries: added allocator for a block of IRQs
  pseries: Separate PCI RTAS setup from common from emulation specific PCI setup
  pseries: Rework irq assignment to avoid carrying qemu_irqs around
  pseries: Remove extraneous prints
  pseries: Update SLOF
  PPC: spapr: Remove global variable
  PPC: spapr: Rework VGA select logic
  xbzrle: fix compilation on ppc32
  spapr: Add support for -vga option
  Add one new file vga-pci.h and cleanup on all platforms
  Revert "PPC: e500: Use new MPIC dt format"
  ppc: Fix bug in handling of PAPR hypercall exits
  PPC: e500: add generic e500 platform
  PPC: e500: split mpc8544ds machine from generic e500 code
  ...

12 years agowin32: provide separate macros for weak decls and definitions
Anthony Liguori [Wed, 15 Aug 2012 03:17:36 +0000 (22:17 -0500)]
win32: provide separate macros for weak decls and definitions

mingw32 seems to want the declaration to also carry the weak attribute.
Strangely, gcc on Linux absolutely does not want the declaration to be marked
as weak.  This may not be the right fix, but it seems to do the trick.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Wed, 15 Aug 2012 18:25:54 +0000 (13:25 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  ivshmem, qdev-monitor: fix order of qerror parameters
  iov_send_recv(): Handle zero bytes case even if OS does not
  framebuffer: Fix spelling in comment (leight -> height)
  Spelling fix in comment (peripherans -> peripherals)
  docs: Fix spelling (propery -> property)
  trace: Fix "Qemu" -> "QEMU"
  cputlb.c: Fix out of date comment
  ehci: fix assertion typo
  Makefile: Avoid explicit list of directories in clean target

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Wed, 15 Aug 2012 18:25:47 +0000 (13:25 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  qemu-iotests: Fix 030 after switch to GenericError
  block: Flush parent to OS with cache=unsafe
  iscsi: Fix NULL dereferences / races between task completion and abort
  monitor: Clean up fd sets on monitor disconnect
  block: Enable qemu_open/close to work with fd sets
  block: Convert close calls to qemu_close
  block: Convert open calls to qemu_open
  block: Prevent detection of /dev/fdset/ as floppy
  qapi: Introduce add-fd, remove-fd, query-fdsets
  qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg

12 years agoopenpic: Added BRR1 register
Bharat Bhushan [Tue, 14 Aug 2012 04:30:55 +0000 (04:30 +0000)]
openpic: Added BRR1 register

Linux mpic driver uses (changes may be in pipeline to get upstreamed soon)
BRR1. This patch adds the support to emulate readonly FSL BRR1 register.

Currently QEMU does not fully emulate any version on MPIC, so the MPIC
Major number and Minor number are set to 0.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Update SLOF firmware image
David Gibson [Tue, 7 Aug 2012 16:10:39 +0000 (16:10 +0000)]
pseries: Update SLOF firmware image

This updates SLOF to handle the necessary device tree properties for MSI
and MSI-X.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries dma: DMA window params added to PHB and DT population changed
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:38 +0000 (16:10 +0000)]
pseries dma: DMA window params added to PHB and DT population changed

Previously the only PCI bus supported was the emulated PCI bus with
fixed DMA window with start at 0 and size 1GB. As we are going to support
PCI pass through which DMA window properties are set by the host
kernel, we have to support DMA windows with parameters other than default.

This patch adds:

1. DMA window properties to sPAPRPHBState: LIOBN (bus id), start,
size of the window.

2. An additional function spapr_dma_dt() to populate DMA window
properties in the device tree which simply accepts all the parameters
and does not try to guess what kind of IOMMU is given to it.
The original spapr_dma_dt() is renamed to spapr_tcet_dma_dt().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Add PCI MSI/MSI-X support
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:37 +0000 (16:10 +0000)]
pseries: Add PCI MSI/MSI-X support

This patch implements MSI and MSI-X support for the pseries PCI host
bridge.  To do this it adds:

 * A "config_space_address to msi_table" map, since the MSI RTAS calls
take a PCI config space address as an identifier.

 * A MSIX memory region to catch msi_notify()/msix_notiry() from
virtio-pci and pass them to the guest via qemu_irq_pulse().

 * RTAS call "ibm,change-msi" which sets up MSI vectors for a
device. Note that this call may configure and return lesser number of
vectors than requested.

 * RTAS call "ibm,query-interrupt-source-number" which translates MSI
vector to interrupt controller (XICS) IRQ number.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: fix error case ndev < 0]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Add trace event for PCI irqs
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:36 +0000 (16:10 +0000)]
pseries: Add trace event for PCI irqs

This adds a trace event in the pseries PCI specific set_irq() function to
assist in debugging.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: add trace.h include]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Export find_phb() utility function for PCI code
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:35 +0000 (16:10 +0000)]
pseries: Export find_phb() utility function for PCI code

The pseries PCI code makes use of an internal find_dev() function which
locates a PCIDevice * given a (platform specific) bus ID and device
address.  Internally this needs to first locate the host bridge on which
the device resides based on the bus ID.  This patch exposes that host
bridge lookup as a separate function, which we will need later in the MSI
and VFIO code.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: drop trace.h inclusion]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: added allocator for a block of IRQs
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:34 +0000 (16:10 +0000)]
pseries: added allocator for a block of IRQs

The patch adds a simple helper which allocates a consecutive sequence
of IRQs calling spapr_allocate_irq for each and checks that allocated
IRQs go consequently.

The patch is required for upcoming support of MSI/MSIX on POWER.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Separate PCI RTAS setup from common from emulation specific PCI setup
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:33 +0000 (16:10 +0000)]
pseries: Separate PCI RTAS setup from common from emulation specific PCI setup

Currently the RTAS functions for handling PCI are registered from the
class init code for the PCI host bridge.  That sort of makes sense
now, but will break in the future when vfio gives us multiple types of
host bridge for pseries (emulated and pass-through, at least).  The
RTAS functions will be common across all host bridge types (and will
call out to different places internally depending on the type).

So, this patch moves the RTAS registration into its own function
called direct from the machine setup code.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Rework irq assignment to avoid carrying qemu_irqs around
Alexey Kardashevskiy [Tue, 7 Aug 2012 16:10:32 +0000 (16:10 +0000)]
pseries: Rework irq assignment to avoid carrying qemu_irqs around

Currently, the interfaces in the pseries machine code for assignment
and setup of interrupts pass around qemu_irq objects.  That was done
in an attempt not to be too closely linked to the specific XICS
interrupt controller.  However interactions with the device tree setup
made that attempt rather futile, and XICS is part of the PAPR spec
anyway, so this really just meant we had to carry both the qemu_irq
pointers and the XICS irq numbers around.

This mess will just get worse when we add upcoming PCI MSI support,
since that will require tracking a bunch more interrupt.  Therefore,
this patch reworks the spapr code to just use XICS irq numbers
(roughly equivalent to GSIs on x86) and only retrieve the qemu_irq
pointers from the XICS code when we need them (a trivial lookup).

This is a reworked and generalized version of an earlier spapr_pci
specific patch from Alexey Kardashevskiy.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: fix checkpath warning]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Remove extraneous prints
David Gibson [Tue, 7 Aug 2012 16:10:31 +0000 (16:10 +0000)]
pseries: Remove extraneous prints

The pseries machine prints several messages to stderr whenever it starts up
and another whenever the vm is reset.  It's not normal for qemu machines to
do this though, so this patch removes them.  We can put them back
conditional on a DEBUG symbol if we really need them in future.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Update SLOF
Benjamin Herrenschmidt [Mon, 30 Jul 2012 20:09:01 +0000 (20:09 +0000)]
pseries: Update SLOF

This patch updates the SLOF version, introducing a number of fixes:
 * add proper graphics support
 * fix bugs with graphical terminal under grub2
 * fix bugs in handling of 64-bit unit addresses
 * fix VSCSI representation to be closer to PowerVM
 * fix bugs which caused grub2 to crash

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: spapr: Remove global variable
Alexander Graf [Tue, 14 Aug 2012 11:22:13 +0000 (13:22 +0200)]
PPC: spapr: Remove global variable

Global variables are bad. Let's move spapr_has_graphics into the
machine state struct.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: spapr: Rework VGA select logic
Alexander Graf [Tue, 14 Aug 2012 11:11:49 +0000 (13:11 +0200)]
PPC: spapr: Rework VGA select logic

When selecting our VGA adapter, we want to:

  * fail completely when we can't satisfy the user's request
  * support -nographic where no VGA adapter should be spawned

This patch reworks the logic so we fulfill the two conditions above.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoxbzrle: fix compilation on ppc32
Alexander Graf [Tue, 14 Aug 2012 10:53:18 +0000 (12:53 +0200)]
xbzrle: fix compilation on ppc32

When compiling the xbzrle code on my ppc32 user space, I hit the following
gcc compiler warning (treated as an error):

  cc1: warnings being treated as errors
  savevm.c: In function ‘xbzrle_encode_buffer’:
  savevm.c:2476: error: overflow in implicit constant conversion

Fix this by making the cast explicit, rather than implicit.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agospapr: Add support for -vga option
zhlcindy@gmail.com [Mon, 6 Aug 2012 16:42:00 +0000 (16:42 +0000)]
spapr: Add support for -vga option

Also instanciate the USB keyboard and mouse when that option is used
(you can still use -device to create individual devices without all
the defaults)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
[agraf: remove USB bits]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoAdd one new file vga-pci.h and cleanup on all platforms
zhlcindy@gmail.com [Mon, 6 Aug 2012 16:41:59 +0000 (16:41 +0000)]
Add one new file vga-pci.h and cleanup on all platforms

Functions pci_vga_init() and pci_cirrus_vga_init() are declared
in pc.h. That prevents other platforms (e.g. sPAPR) to use them.

This patch is to create one new file vga-pci.h and move the
declarations to vga-pci.h, so that they can be shared by
all platforms. This patch also cleans up on all platforms.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoRevert "PPC: e500: Use new MPIC dt format"
Alexander Graf [Thu, 9 Aug 2012 20:57:14 +0000 (22:57 +0200)]
Revert "PPC: e500: Use new MPIC dt format"

This reverts commit 518c7fb44f2182cde943dc64f88cb2fd4e4ff6b5. It breaks
new Linux guests with SMP, because IPIs get mapped to large vectors which
our MPIC emulation does not implement.

Conflicts:

hw/ppc/e500.c

12 years agoppc: Fix bug in handling of PAPR hypercall exits
David Gibson [Mon, 6 Aug 2012 18:44:45 +0000 (18:44 +0000)]
ppc: Fix bug in handling of PAPR hypercall exits

Currently for powerpc, kvm_arch_handle_exit() always returns 1, meaning
that its caller - kvm_cpu_exec() - will always exit immediately afterwards
to the loop in qemu_kvm_cpu_thread_fn().

There's no need to do this.  Once we've handled the hypercall there's no
reason we can't go straight around and KVM_RUN again, which is what ret = 0
will signal.  The only exception might be for hypercalls which affect the
state of cpu_can_run(), however the only one that might do this is H_CEDE
and for kvm that is always handled in the kernel, not qemu.

Furtherm setting ret = 0 means that when exit_requested is set from a
hypercall, we will enter KVM_RUN once more with a signal which lets the
the kernel do its internal logic to complete the hypercall with out
actually executing any more guest code.  This is important if our hypercall
also triggered a reset, which previously would re-initialize everything
without completing the hypercall.  This caused the kernel to get confused
because it thought the guest was still in the middle of a hypercall when
it has actually been reset.

This patch therefore changes to ret = 0, which is both a bugfix and a small
optimization.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: e500: add generic e500 platform
Scott Wood [Mon, 2 Jul 2012 13:03:21 +0000 (13:03 +0000)]
PPC: e500: add generic e500 platform

This gives the kernel a paravirtualized machine to target, without
requiring both sides to pretend to be targeting a specific board
that likely has little to do with the host in KVM scenarios.  This
avoids the need to add new boards to QEMU, just to be able to
run KVM on new CPUs.

Signed-off-by: Scott Wood <scottwood@freescale.com>
[agraf: conditionalize on CONFIG_FDT]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: e500: split mpc8544ds machine from generic e500 code
Scott Wood [Mon, 2 Jul 2012 13:03:20 +0000 (13:03 +0000)]
PPC: e500: split mpc8544ds machine from generic e500 code

Currently the only mpc8544ds-ism that is factored out is
toplevel compatible and model.  In the future the generic e500
code is expected to become more generic.

Signed-off-by: Scott Wood <scottwood@freescale.com>
[agraf: conditionalize on CONFIG_FDT]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: e500: change internal references away from mpc8544ds
Scott Wood [Mon, 2 Jul 2012 13:03:19 +0000 (13:03 +0000)]
PPC: e500: change internal references away from mpc8544ds

No functional changes -- machine is still outwardly mpc8544ds.

The references that are not changed contain mpc8544 hardware details that
need to be parameterized if/when a different e500 platform wants to
change them.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: e500: rename mpc8544ds into generic file
Scott Wood [Mon, 2 Jul 2012 13:03:18 +0000 (13:03 +0000)]
PPC: e500: rename mpc8544ds into generic file

Rename the file (with no changes other than fixing up the header paths)
in preparation for refactoring into a generic e500 platform.  Also move
it into the newly created ppc/ directory.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
[agraf: conditionalize on CONFIG_FDT]
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries pci: spapr_populate_pci_devices renamed to spapr_populate_pci_dt
Alexey Kardashevskiy [Wed, 13 Jun 2012 18:40:06 +0000 (18:40 +0000)]
pseries pci: spapr_populate_pci_devices renamed to spapr_populate_pci_dt

spapr_populate_pci_devices() populates the device tree only with bus
properties and has nothing to do with the devices on it as PCI BAR
allocation is done by the system firmware (SLOF).

New name - spapr_populate_pci_dt() - describes the functionality better.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries pci: removed redundant busdev
Alexey Kardashevskiy [Wed, 13 Jun 2012 18:38:50 +0000 (18:38 +0000)]
pseries pci: removed redundant busdev

The PCIHostState struct already contains SysBusDevice so
the one in sPAPRPHBState has to go.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoMerge remote-tracking branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Wed, 15 Aug 2012 16:15:02 +0000 (11:15 -0500)]
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

* qemu-kvm/uq/master:
  update-linux-headers.sh: Pull in asm-generic/kvm_para.h
  kvmvapic: Disable if there is insufficient memory
  kvm: i8254: Finish time conversion fix
  kvm: i8254: Cache kernel clock offset in KVMPITState

12 years agoMerge remote-tracking branch 'stefanha/tracing' into staging
Anthony Liguori [Wed, 15 Aug 2012 16:14:06 +0000 (11:14 -0500)]
Merge remote-tracking branch 'stefanha/tracing' into staging

* stefanha/tracing:
  trace/simple: Replace asprintf by g_strdup_printf
  trace/simple: Fix compiler warning for 32 bit hosts
  trace: avoid pointer aliasing in trace_record_finish()
  trace: drop unused TraceBufferRecord->next_tbuf_idx field
  trace: remove unnecessary write_to_buffer() typecasting
  trace: rename TraceRecordHeader to TraceLogHeader

12 years agos390: provide interface for service interrupt/introduce interrupt.c
Christian Borntraeger [Mon, 23 Jul 2012 21:37:05 +0000 (21:37 +0000)]
s390: provide interface for service interrupt/introduce interrupt.c

This patch creates interrupt.c. The first user is a callback for hw/*
code to trigger an service interrupt for a given sccb value. Several
interrupt types for s390 are floating (can be delivered to all CPUs).
so this code does not belong to a specific CPU.
Other interrupts (like the virtio one) are also floating and can be
moved here later on.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390: Fix error handling and condition code of service call
Christian Borntraeger [Mon, 23 Jul 2012 21:37:04 +0000 (21:37 +0000)]
s390: Fix error handling and condition code of service call

Invalid sccb addresses will cause specification or addressing exception.
Lets add those checks. Furthermore, the good case (cc=0) was incorrect
for KVM, we did not set the CC at all. We now use return codes < 0
as program checks and return codes > 0 as condition code values.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoivshmem, qdev-monitor: fix order of qerror parameters
Alberto Garcia [Tue, 14 Aug 2012 11:41:28 +0000 (14:41 +0300)]
ivshmem, qdev-monitor: fix order of qerror parameters

Now that the QERR_ macros no longer contain a json dictionary,
the order of some parameters needs to be fixed for them to appear
correctly.

Signed-off-by: Alberto Garcia <agarcia@igalia.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoiov_send_recv(): Handle zero bytes case even if OS does not
Peter Maydell [Sat, 11 Aug 2012 21:24:35 +0000 (22:24 +0100)]
iov_send_recv(): Handle zero bytes case even if OS does not

POSIX allows sendmsg() and recvmsg() to fail EMSGSIZE if passed a zero
msg.msg_iovlen (in particular the MacOS X implementation will do this).
Handle the case where iov_send_recv() is passed a zero byte count
explicitly, to avoid accidentally depending on the OS to treat zero
msg_iovlen as a no-op.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoframebuffer: Fix spelling in comment (leight -> height)
Stefan Weil [Sat, 11 Aug 2012 19:32:02 +0000 (21:32 +0200)]
framebuffer: Fix spelling in comment (leight -> height)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoSpelling fix in comment (peripherans -> peripherals)
Stefan Weil [Fri, 10 Aug 2012 19:56:46 +0000 (21:56 +0200)]
Spelling fix in comment (peripherans -> peripherals)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agodocs: Fix spelling (propery -> property)
Stefan Weil [Fri, 10 Aug 2012 19:53:02 +0000 (21:53 +0200)]
docs: Fix spelling (propery -> property)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agotrace: Fix "Qemu" -> "QEMU"
Stefan Weil [Fri, 10 Aug 2012 19:48:07 +0000 (21:48 +0200)]
trace: Fix "Qemu" -> "QEMU"

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agocputlb.c: Fix out of date comment
Peter Maydell [Fri, 10 Aug 2012 16:14:05 +0000 (17:14 +0100)]
cputlb.c: Fix out of date comment

The comment about the return address from get_page_addr_code() was
well out of date as phys_ram_base has not existed for some time.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoehci: fix assertion typo
Alejandro Martinez Ruiz [Tue, 14 Aug 2012 14:13:02 +0000 (16:13 +0200)]
ehci: fix assertion typo

Signed-off-by: Alejandro Martinez Ruiz <alex@securiforest.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoMakefile: Avoid explicit list of directories in clean target
Peter Maydell [Wed, 15 Aug 2012 11:29:24 +0000 (12:29 +0100)]
Makefile: Avoid explicit list of directories in clean target

Avoid having an explicit list of directories in the 'clean'
target by using 'find' to remove all .o and .d files instead.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqemu-iotests: Fix 030 after switch to GenericError
Kevin Wolf [Wed, 15 Aug 2012 12:08:56 +0000 (14:08 +0200)]
qemu-iotests: Fix 030 after switch to GenericError

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoblock: Flush parent to OS with cache=unsafe
Kevin Wolf [Wed, 15 Aug 2012 10:52:45 +0000 (12:52 +0200)]
block: Flush parent to OS with cache=unsafe

Commit 29cdb251 already added a comment that no unnecessary flushes to
disk will occur, this patch makes the code even get to the point of the
comment. This is mostly theoretical because in practice we only stack
one format on top of one protocol, the former implementing flush_to_os
and the latter only flush_to_disk. It starts to matter when drivers that
are not on top implement flush_to_os.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoiscsi: Fix NULL dereferences / races between task completion and abort
Stefan Priebe [Wed, 15 Aug 2012 07:09:54 +0000 (09:09 +0200)]
iscsi: Fix NULL dereferences / races between task completion and abort

Signed-off-by: Stefan Priebe <s.priebe@profihost.ag>
Acked-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agomonitor: Clean up fd sets on monitor disconnect
Corey Bryant [Tue, 14 Aug 2012 20:43:48 +0000 (16:43 -0400)]
monitor: Clean up fd sets on monitor disconnect

Fd sets are shared by all monitor connections.  Fd sets are considered
to be in use while at least one monitor is connected.  When the last
monitor disconnects, all fds that are members of an fd set with no
outstanding dup references are closed.  This prevents any fd leakage
associated with a client disconnect prior to using a passed fd.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: Enable qemu_open/close to work with fd sets
Corey Bryant [Tue, 14 Aug 2012 20:43:47 +0000 (16:43 -0400)]
block: Enable qemu_open/close to work with fd sets

When qemu_open is passed a filename of the "/dev/fdset/nnn"
format (where nnn is the fdset ID), an fd with matching access
mode flags will be searched for within the specified monitor
fd set.  If the fd is found, a dup of the fd will be returned
from qemu_open.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: Convert close calls to qemu_close
Corey Bryant [Tue, 14 Aug 2012 20:43:46 +0000 (16:43 -0400)]
block: Convert close calls to qemu_close

This patch converts all block layer close calls, that correspond
to qemu_open calls, to qemu_close.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: Convert open calls to qemu_open
Corey Bryant [Tue, 14 Aug 2012 20:43:45 +0000 (16:43 -0400)]
block: Convert open calls to qemu_open

This patch converts all block layer open calls to qemu_open.

Note that this adds the O_CLOEXEC flag to the changed open paths
when the O_CLOEXEC macro is defined.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: Prevent detection of /dev/fdset/ as floppy
Corey Bryant [Tue, 14 Aug 2012 20:43:44 +0000 (16:43 -0400)]
block: Prevent detection of /dev/fdset/ as floppy

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqapi: Introduce add-fd, remove-fd, query-fdsets
Corey Bryant [Tue, 14 Aug 2012 20:43:43 +0000 (16:43 -0400)]
qapi: Introduce add-fd, remove-fd, query-fdsets

This patch adds support that enables passing of file descriptors
to the QEMU monitor where they will be stored in specified file
descriptor sets.

A file descriptor set can be used by a client like libvirt to
store file descriptors for the same file.  This allows the
client to open a file with different access modes (O_RDWR,
O_WRONLY, O_RDONLY) and add/remove the passed fds to/from an fd
set as needed.  This will allow QEMU to (in a later patch in this
series) "open" and "reopen" the same file by dup()ing the fd in
the fd set that corresponds to the file, where the fd has the
matching access mode flag that QEMU requests.

The new QMP commands are:
  add-fd: Add a file descriptor to an fd set
  remove-fd: Remove a file descriptor from an fd set
  query-fdsets: Return information describing all fd sets

Note: These commands are not compatible with the existing getfd
and closefd QMP commands.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg
Corey Bryant [Tue, 14 Aug 2012 20:43:42 +0000 (16:43 -0400)]
qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg

Set the close-on-exec flag for the file descriptor received
via SCM_RIGHTS.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoupdate-linux-headers.sh: Pull in asm-generic/kvm_para.h
Peter Maydell [Wed, 25 Jul 2012 15:29:07 +0000 (16:29 +0100)]
update-linux-headers.sh: Pull in asm-generic/kvm_para.h

Add asm-generic/kvm_para.h to the set of non-architecture specific
KVM kernel headers we copy into QEMU. This header may be included
by an architecture's kvm_para.h header.

Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agokvmvapic: Disable if there is insufficient memory
Jan Kiszka [Tue, 14 Aug 2012 11:43:12 +0000 (13:43 +0200)]
kvmvapic: Disable if there is insufficient memory

We need at least 1M of RAM to map the option ROM. Otherwise, we will
corrupt host memory or even crash:

    $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -m 640k
    Segmentation fault (core dumped)

Reported-and-tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agokvm: i8254: Finish time conversion fix
Jan Kiszka [Tue, 14 Aug 2012 08:24:47 +0000 (10:24 +0200)]
kvm: i8254: Finish time conversion fix

0cdd3d1444 fixed reading back the counter load time from the kernel
while assuming the kernel would always update its load time on writing
the state. That is only true for channel 1, and so pit_get_channel_info
returned wrong output pin states for high counter values.

Fix this by applying the offset also on kvm_pit_put. Now we also need to
update the offset when we write the state while the VM is stopped as it
keeps on changing in that state.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agokvm: i8254: Cache kernel clock offset in KVMPITState
Jan Kiszka [Tue, 14 Aug 2012 08:24:03 +0000 (10:24 +0200)]
kvm: i8254: Cache kernel clock offset in KVMPITState

To prepare the final fix for clock calibration issues with the in-kernel
PIT, we want to cache the offset between vmclock and the clock used by
the in-kernel PIT. So far, we only need to update it when the VM state
changes between running and stopped because we only read the in-kernel
PIT state while the VM is running.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agoMerge remote-tracking branch 'origin/master' into staging
Anthony Liguori [Tue, 14 Aug 2012 20:19:50 +0000 (15:19 -0500)]
Merge remote-tracking branch 'origin/master' into staging

* origin/master:
  linux-user: ARM: Ignore immediate value for svc in thumb mode
  linux-user: Use init_guest_space when -R and -B are specified
  linux-user: Factor out guest space probing into a function
  flatload: fix bss clearing
  linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
  linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
  linux-user: pass sockaddr from host to target
  x86: switch to AREG0 free mode
  x86: avoid AREG0 in segmentation helpers
  x86: avoid AREG0 for misc helpers
  x86: use wrappers for memory access helpers
  x86: avoid AREG0 for SMM helpers
  x86: avoid AREG0 for SVM helpers
  x86: avoid AREG0 for integer helpers
  x86: avoid AREG0 for condition code helpers
  x86: avoid AREG0 for FPU helpers
  linux-user: Move target_to_host_errno_table[] setup out of ioctl loop
  linux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions
  linux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET

12 years agoMerge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm
Blue Swirl [Tue, 14 Aug 2012 19:50:22 +0000 (19:50 +0000)]
Merge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm

* 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm:
  linux-user: ARM: Ignore immediate value for svc in thumb mode
  linux-user: Use init_guest_space when -R and -B are specified
  linux-user: Factor out guest space probing into a function
  flatload: fix bss clearing
  linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
  linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
  linux-user: pass sockaddr from host to target
  linux-user: Move target_to_host_errno_table[] setup out of ioctl loop
  linux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions
  linux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET

12 years agolinux-user: ARM: Ignore immediate value for svc in thumb mode
Alexander Graf [Tue, 29 May 2012 05:30:26 +0000 (05:30 +0000)]
linux-user: ARM: Ignore immediate value for svc in thumb mode

When running in thumb mode, Linux doesn't evaluate the immediate value
of the svc instruction, but instead just always assumes the syscall number
to be in r7.

This fixes executing go_bootstrap while building go for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: Use init_guest_space when -R and -B are specified
Meador Inge [Thu, 26 Jul 2012 16:50:02 +0000 (16:50 +0000)]
linux-user: Use init_guest_space when -R and -B are specified

Roll the code used to initialize the guest memory space when -R
or -B is used into 'init_guest_space' and then call 'init_guest_space'
from the driver.  This way the reserved guest memory space can
be probed for.  Calling 'mmap' just once as is currently done is not
guaranteed to succeed since the host address space validation might fail.

Signed-off-by: Meador Inge <meadori@codesourcery.com>
[PMM: Fixed minor whitespace errors.]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: Factor out guest space probing into a function
Meador Inge [Thu, 26 Jul 2012 16:50:01 +0000 (16:50 +0000)]
linux-user: Factor out guest space probing into a function

Signed-off-by: Meador Inge <meadori@codesourcery.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agoflatload: fix bss clearing
Mike Frysinger [Mon, 9 Jul 2012 03:04:57 +0000 (03:04 +0000)]
flatload: fix bss clearing

The current bss clear logic assumes the target mmap address and host
address are the same.  Use g2h to translate from the target address
space to the host so we can call memset on it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
Jing Huang [Tue, 24 Jul 2012 14:01:42 +0000 (14:01 +0000)]
linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
Jing Huang [Tue, 24 Jul 2012 13:59:23 +0000 (13:59 +0000)]
linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agolinux-user: pass sockaddr from host to target
Jing Huang [Tue, 24 Jul 2012 13:58:02 +0000 (13:58 +0000)]
linux-user: pass sockaddr from host to target

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agox86: switch to AREG0 free mode
Blue Swirl [Sun, 29 Apr 2012 20:35:48 +0000 (20:35 +0000)]
x86: switch to AREG0 free mode

Add an explicit CPUX86State parameter instead of relying on AREG0.

Remove temporary wrappers and switch to AREG0 free mode.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 in segmentation helpers
Blue Swirl [Sun, 29 Apr 2012 19:47:06 +0000 (19:47 +0000)]
x86: avoid AREG0 in segmentation helpers

Add an explicit CPUX86State parameter instead of relying on AREG0.

Rename remains of op_helper.c to seg_helper.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 for misc helpers
Blue Swirl [Sun, 29 Apr 2012 18:42:47 +0000 (18:42 +0000)]
x86: avoid AREG0 for misc helpers

Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: use wrappers for memory access helpers
Blue Swirl [Sun, 29 Apr 2012 19:11:01 +0000 (19:11 +0000)]
x86: use wrappers for memory access helpers

Switch to wrapped versions of memory access functions.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 for SMM helpers
Blue Swirl [Sun, 29 Apr 2012 17:54:21 +0000 (17:54 +0000)]
x86: avoid AREG0 for SMM helpers

Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 for SVM helpers
Blue Swirl [Sun, 29 Apr 2012 15:51:49 +0000 (15:51 +0000)]
x86: avoid AREG0 for SVM helpers

Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 for integer helpers
Blue Swirl [Sun, 29 Apr 2012 14:11:56 +0000 (14:11 +0000)]
x86: avoid AREG0 for integer helpers

Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 for condition code helpers
Blue Swirl [Sun, 29 Apr 2012 12:45:34 +0000 (12:45 +0000)]
x86: avoid AREG0 for condition code helpers

Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agox86: avoid AREG0 for FPU helpers
Blue Swirl [Sat, 28 Apr 2012 21:28:09 +0000 (21:28 +0000)]
x86: avoid AREG0 for FPU helpers

Make FPU helpers take a parameter for CPUState instead
of relying on global env.

Introduce temporary wrappers for FPU load and store ops. Remove
wrappers for non-AREG0 code. Don't call unconverted helpers
directly.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMerge remote-tracking branch 'kraxel/seabios-5a02306' into staging
Anthony Liguori [Tue, 14 Aug 2012 18:46:35 +0000 (13:46 -0500)]
Merge remote-tracking branch 'kraxel/seabios-5a02306' into staging

* kraxel/seabios-5a02306:
  update seabios to latest master