]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
8 years agotarget-ppc: Include missing MMU models for SDR1 in info registers
David Gibson [Mon, 8 Feb 2016 23:28:43 +0000 (09:28 +1000)]
target-ppc: Include missing MMU models for SDR1 in info registers

The HMP command "info registers" produces somewhat different information on
different ppc cpu variants.  For those with a hash MMU it's supposed to
include the SDR1, DAR and DSISR registers related to the MMU.  However,
the switch is missing a couple of MMU model variants, meaning we will
miss out this information on certain CPUs which should have it.

This patch corrects the oversight.  (Really these MMU model IDs need a big
cleanup, but we might as well fix the bug in the interim).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
8 years agotarget-ppc: Remove unused kvmppc_update_sdr1() stub
David Gibson [Mon, 8 Feb 2016 23:28:25 +0000 (09:28 +1000)]
target-ppc: Remove unused kvmppc_update_sdr1() stub

This KVM stub implementation isn't used anywhere.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
8 years agohw: fix some debug message format strings
Alyssa Milburn [Thu, 4 Feb 2016 18:40:57 +0000 (18:40 +0000)]
hw: fix some debug message format strings

Signed-off-by: Alyssa Milburn <fuzzie@fuzzie.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
Peter Maydell [Tue, 16 Feb 2016 17:31:56 +0000 (17:31 +0000)]
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

* Coverity fixes for IPMI and mptsas
* qemu-char fixes from Daniel and Marc-André
* Bug fixes that break qemu-iotests
* Changes to fix reset from panicked state
* checkpatch false positives for designated initializers
* TLS support in the NBD servers and clients

# gpg: Signature made Tue 16 Feb 2016 16:27:17 GMT using RSA key ID 78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>"

* remotes/bonzini/tags/for-upstream: (28 commits)
  nbd: enable use of TLS with nbd-server-start command
  nbd: enable use of TLS with qemu-nbd server
  nbd: enable use of TLS with NBD block driver
  nbd: implement TLS support in the protocol negotiation
  nbd: use "" as a default export name if none provided
  nbd: always query export list in fixed new style protocol
  nbd: allow setting of an export name for qemu-nbd server
  nbd: make client request fixed new style if advertised
  nbd: make server compliant with fixed newstyle spec
  nbd: invert client logic for negotiating protocol version
  nbd: convert to using I/O channels for actual socket I/O
  nbd: convert blockdev NBD server to use I/O channels for connection setup
  nbd: convert qemu-nbd server to use I/O channels for connection setup
  nbd: convert block client to use I/O channels for connection setup
  qemu-nbd: add support for --object command line arg
  qom: add helpers for UserCreatable object types
  ipmi: sensor number should not exceed MAX_SENSORS
  mptsas: fix wrong formula
  mptsas: fix memory leak
  mptsas: add missing va_end
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agonbd: enable use of TLS with nbd-server-start command
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:14 +0000 (18:41 +0000)]
nbd: enable use of TLS with nbd-server-start command

This modifies the nbd-server-start QMP command so that it
is possible to request use of TLS. This is done by adding
a new optional parameter "tls-creds" which provides the ID
of a previously created QCryptoTLSCreds object instance.

TLS is only supported when using an IPv4/IPv6 socket listener.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-17-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: enable use of TLS with qemu-nbd server
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:13 +0000 (18:41 +0000)]
nbd: enable use of TLS with qemu-nbd server

This modifies the qemu-nbd program so that it is possible to
request the use of TLS with the server. It simply adds a new
command line option --tls-creds which is used to provide the
ID of a QCryptoTLSCreds object previously created via the
--object command line option.

For example

  qemu-nbd --object tls-creds-x509,id=tls0,endpoint=server,\
                    dir=/home/berrange/security/qemutls \
           --tls-creds tls0 \
           --exportname default

TLS requires the new style NBD protocol, so if no export name
is set (via --export-name), then we use the default NBD protocol
export name ""

TLS is only supported when using an IPv4/IPv6 socket listener.
It is not possible to use with UNIX sockets, which includes
when connecting the NBD server to a host device.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-16-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: enable use of TLS with NBD block driver
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:12 +0000 (18:41 +0000)]
nbd: enable use of TLS with NBD block driver

This modifies the NBD driver so that it is possible to request
use of TLS. This is done by providing the 'tls-creds' parameter
with the ID of a previously created QCryptoTLSCreds object.

For example

  $QEMU -object tls-creds-x509,id=tls0,endpoint=client,\
                dir=/home/berrange/security/qemutls \
        -drive driver=nbd,host=localhost,port=9000,tls-creds=tls0

The client will drop the connection if the NBD server does not
provide TLS.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-15-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: implement TLS support in the protocol negotiation
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:11 +0000 (18:41 +0000)]
nbd: implement TLS support in the protocol negotiation

This extends the NBD protocol handling code so that it is capable
of negotiating TLS support during the connection setup. This involves
requesting the STARTTLS protocol option before any other NBD options.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-14-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: use "" as a default export name if none provided
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:10 +0000 (18:41 +0000)]
nbd: use "" as a default export name if none provided

If the user does not provide an export name and the server
is running the new style protocol, where export names are
mandatory, use "" as the default export name if the user
has not specified any. "" is defined in the NBD protocol
as the default name to use in such scenarios.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-13-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: always query export list in fixed new style protocol
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:09 +0000 (18:41 +0000)]
nbd: always query export list in fixed new style protocol

With the new style protocol, the NBD client will currenetly
send NBD_OPT_EXPORT_NAME as the first (and indeed only)
option it wants. The problem is that the NBD protocol spec
does not allow for returning an error message with the
NBD_OPT_EXPORT_NAME option. So if the server mandates use
of TLS, the client will simply see an immediate connection
close after issuing NBD_OPT_EXPORT_NAME which is not user
friendly.

To improve this situation, if we have the fixed new style
protocol, we can sent NBD_OPT_LIST as the first option
to query the list of server exports. We can check for our
named export in this list and raise an error if it is not
found, instead of going ahead and sending NBD_OPT_EXPORT_NAME
with a name that we know will be rejected.

This improves the error reporting both in the case that the
server required TLS, and in the case that the client requested
export name does not exist on the server.

If the server does not support NBD_OPT_LIST, we just ignore
that and carry on with NBD_OPT_EXPORT_NAME as before.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-12-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: allow setting of an export name for qemu-nbd server
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:08 +0000 (18:41 +0000)]
nbd: allow setting of an export name for qemu-nbd server

The qemu-nbd server currently always uses the old style protocol
since it never sets any export name. This is a problem because
future TLS support will require use of the new style protocol
negotiation.

This adds "--exportname NAME" / "-x NAME" arguments to qemu-nbd
which allow the user to set an explicit export name. When an
export name is set the server will always use the new style
NBD protocol.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-11-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: make client request fixed new style if advertised
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:07 +0000 (18:41 +0000)]
nbd: make client request fixed new style if advertised

If the server advertises support for the fixed new style
negotiation, the client should in turn enable new style.
This will allow the client to negotiate further NBD
options besides the export name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-10-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: make server compliant with fixed newstyle spec
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:06 +0000 (18:41 +0000)]
nbd: make server compliant with fixed newstyle spec

If the client does not request the fixed new style protocol,
then we should only accept NBD_OPT_EXPORT_NAME. All other
options are only valid when fixed new style has been activated.

The qemu-nbd client doesn't currently request fixed new style
protocol, but this change won't break qemu-nbd, because it
fortunately only ever uses NBD_OPT_EXPORT_NAME, so was never
triggering the non-compliant server behaviour.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-9-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: invert client logic for negotiating protocol version
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:05 +0000 (18:41 +0000)]
nbd: invert client logic for negotiating protocol version

The nbd_receive_negotiate() method takes different code
paths based on whether 'name == NULL', and then checks
the expected protocol version in each branch.

This patch inverts the logic, so that it takes different
code paths based on what protocol version it receives and
then checks if name is NULL or not as needed.

This facilitates later code which allows the client to
be capable of using the new style protocol regardless
of whether an export name is listed or not.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-8-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: convert to using I/O channels for actual socket I/O
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:04 +0000 (18:41 +0000)]
nbd: convert to using I/O channels for actual socket I/O

Now that all callers are converted to use I/O channels for
initial connection setup, it is possible to switch the core
NBD protocol handling core over to use QIOChannel APIs for
actual sockets I/O.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-7-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: convert blockdev NBD server to use I/O channels for connection setup
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:03 +0000 (18:41 +0000)]
nbd: convert blockdev NBD server to use I/O channels for connection setup

This converts the blockdev NBD server to use the QIOChannelSocket
class for initial listener socket setup and accepting of client
connections. Actual I/O is still being performed against the
socket file descriptor using the POSIX socket APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-6-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: convert qemu-nbd server to use I/O channels for connection setup
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:02 +0000 (18:41 +0000)]
nbd: convert qemu-nbd server to use I/O channels for connection setup

This converts the qemu-nbd server to use the QIOChannelSocket
class for initial listener socket setup and accepting of client
connections. Actual I/O is still being performed against the
socket file descriptor using the POSIX socket APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-5-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agonbd: convert block client to use I/O channels for connection setup
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:01 +0000 (18:41 +0000)]
nbd: convert block client to use I/O channels for connection setup

This converts the NBD block driver client to use the QIOChannelSocket
class for initial connection setup. The NbdClientSession struct has
two pointers, one to the master QIOChannelSocket providing the raw
data channel, and one to a QIOChannel which is the current channel
used for I/O. Initially the two point to the same object, but when
TLS support is added, they will point to different objects.

The qemu-img & qemu-io tools now need to use MODULE_INIT_QOM to
ensure the QIOChannel object classes are registered. The qemu-nbd
tool already did this.

In this initial conversion though, all I/O is still actually done
using the raw POSIX sockets APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-4-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoqemu-nbd: add support for --object command line arg
Daniel P. Berrange [Wed, 10 Feb 2016 18:41:00 +0000 (18:41 +0000)]
qemu-nbd: add support for --object command line arg

Allow creation of user creatable object types with qemu-nbd
via a new --object command line arg. This will be used to supply
passwords and/or encryption keys to the various block driver
backends via the recently added 'secret' object type.

 # printf letmein > mypasswd.txt
 # qemu-nbd --object secret,id=sec0,file=mypasswd.txt \
      ...other nbd args...

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-3-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoqom: add helpers for UserCreatable object types
Daniel P. Berrange [Wed, 10 Feb 2016 18:40:59 +0000 (18:40 +0000)]
qom: add helpers for UserCreatable object types

The QMP monitor code has two helper methods object_add
and qmp_object_del that are called from several places
in the code (QMP, HMP and main emulator startup).

The HMP and main emulator startup code also share
further logic that extracts the qom-type & id
values from a qdict.

We soon need to use this logic from qemu-img, qemu-io
and qemu-nbd too, but don't want those to depend on
the monitor, nor do we want to duplicate the code.

To avoid this, move some code out of qmp.c and hmp.c
adding new methods to qom/object_interfaces.c

 - user_creatable_add - takes a QDict holding a full
   object definition & instantiates it
 - user_creatable_add_type - takes an ID, type name,
   and QDict holding object properties & instantiates
   it
 - user_creatable_add_opts - takes a QemuOpts holding
   a full object definition & instantiates it
 - user_creatable_add_opts_foreach - variant on
   user_creatable_add_opts which can be directly used
   in conjunction with qemu_opts_foreach.
 - user_creatable_del - takes an ID and deletes the
   corresponding object

The existing code is updated to use these new methods.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-2-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-io-next-2016-02-16-1' into...
Peter Maydell [Tue, 16 Feb 2016 15:47:35 +0000 (15:47 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/pull-io-next-2016-02-16-1' into staging

Merge I/O fixes 2016/02/16 v1

# gpg: Signature made Tue 16 Feb 2016 15:42:29 GMT using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"

* remotes/berrange/tags/pull-io-next-2016-02-16-1:
  io: convert QIOChannelBuffer to use uint8_t instead of char
  io: introduce helper for creating channels from file descriptors
  io: improve docs for QIOChannelSocket async functions

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoipmi: sensor number should not exceed MAX_SENSORS
Cédric Le Goater [Tue, 16 Feb 2016 08:05:44 +0000 (09:05 +0100)]
ipmi: sensor number should not exceed MAX_SENSORS

Fix a number of off-by-ones, one of them spotted by Coverity.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agomptsas: fix wrong formula
Paolo Bonzini [Tue, 16 Feb 2016 07:49:15 +0000 (08:49 +0100)]
mptsas: fix wrong formula

MPI_DOORBELL_WHO_INIT_SHIFT is being repeated twice.  Reported
by Coverity.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agomptsas: fix memory leak
Paolo Bonzini [Tue, 16 Feb 2016 07:41:52 +0000 (08:41 +0100)]
mptsas: fix memory leak

Reported by Coverity.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agomptsas: add missing va_end
Paolo Bonzini [Tue, 16 Feb 2016 07:35:49 +0000 (08:35 +0100)]
mptsas: add missing va_end

Reported by Coverity.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agomigration: fix incorrect memory_global_dirty_log_start outside BQL
Paolo Bonzini [Mon, 15 Feb 2016 18:57:57 +0000 (19:57 +0100)]
migration: fix incorrect memory_global_dirty_log_start outside BQL

This can cause various segmentation faults or aborts in qemu-iotests
test 091.

Fixes: 5b82b703b69acc67b78b98a5efc897a3912719eb
Cc: Dave Gilbert <dgilbert@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agooslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h
Peter Maydell [Mon, 8 Feb 2016 19:08:10 +0000 (19:08 +0000)]
oslib-posix.c: Move workaround for OSX daemon() deprecation to osdep.h

The right place for "work around issues with system headers" code
is osdep.h. Move the workaround for OSX's stdlib.h emitting a
deprecation warning for daemon() to that header.

This also fixes a problem where running clean-includes on
oslib-posix.c would erroneously remove the #include <stdlib.h>
from it, breaking the workaround.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoall: Clean up includes
Peter Maydell [Mon, 8 Feb 2016 19:01:23 +0000 (19:01 +0000)]
all: Clean up includes

Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoscripts/tracetool: Include qemu/osdep.h in generated .c files
Peter Maydell [Mon, 8 Feb 2016 18:53:31 +0000 (18:53 +0000)]
scripts/tracetool: Include qemu/osdep.h in generated .c files

Include qemu/osdep.h as the first include in generated .c files,
so they don't implicitly rely on some other included header
to pull it in.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoscripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h
Peter Maydell [Mon, 8 Feb 2016 19:17:08 +0000 (19:17 +0000)]
scripts/feature_to_c.sh: Include qemu/osdep.h rather than config.h

In the .c files generated by this script, include qemu/osdep.h
as the first included header, not config.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoqapi: Clean up includes in generated files
Eric Blake [Mon, 8 Feb 2016 15:36:46 +0000 (08:36 -0700)]
qapi: Clean up includes in generated files

As a followup to commit cbf2115, clean up the includes in files
generated by QAPI so that osdep.h is included first in .c files,
and headers which it implies are not included manually.  This
patch is done manually, since Coccinelle (and therefore
scripts/clean-includes) doesn't see into the generator scripts.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotests: Clean up includes
Peter Maydell [Mon, 8 Feb 2016 18:08:51 +0000 (18:08 +0000)]
tests: Clean up includes

Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Eric Blake <eblake@redhat.com>
8 years agotests/i440fx-test: Don't define ARRAY_SIZE locally
Peter Maydell [Mon, 8 Feb 2016 18:37:01 +0000 (18:37 +0000)]
tests/i440fx-test: Don't define ARRAY_SIZE locally

Don't define ARRAY_SIZE locally; instead include osdep.h for it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agolibdecnumber: Clean up includes
Peter Maydell [Tue, 9 Feb 2016 11:02:46 +0000 (11:02 +0000)]
libdecnumber: Clean up includes

Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agocris: Clean up includes
Peter Maydell [Tue, 9 Feb 2016 10:55:48 +0000 (10:55 +0000)]
cris: Clean up includes

Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agotarget-cris: Remove unnecessary ifdef from mmu.c
Peter Maydell [Tue, 9 Feb 2016 10:54:10 +0000 (10:54 +0000)]
target-cris: Remove unnecessary ifdef from mmu.c

mmu.c is only built for CONFIG_SOFTMMU targets, so there is
no need to redundantly surround the whole file contents with
an #ifndef CONFIG_USER_ONLY. The ifdef also confuses the
Coccinelle tool.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agohw/block/nand.c: Include osdep.h first
Peter Maydell [Mon, 8 Feb 2016 19:11:45 +0000 (19:11 +0000)]
hw/block/nand.c: Include osdep.h first

Include osdep.h as the first header in nand.c; this has to be
done manually because coccinelle gets confused by the way that
this C file includes itself.

We fix some odd spacing in #includes while we are in the area.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agobuild: Don't redefine 'inline'
Eric Blake [Tue, 9 Feb 2016 18:49:48 +0000 (11:49 -0700)]
build: Don't redefine 'inline'

Actively redefining 'inline' is wrong for C++, where gcc has an
extension 'inline namespace' which fails to compile if the
keyword 'inline' is replaced by a macro expansion.  This will
matter once we start to include "qemu/osdep.h" first from C++
files, depending also on whether the system headers are new
enough to be using the gcc extension.

But rather than just guard things by __cplusplus, let's look at
the overall picture.  Commit df2542c737ea2 in 2007 defined 'inline'
to the gcc attribute __always_inline__, with the rationale "To
avoid discarded inlining bug".  But compilers have improved since
then, and we are probably better off trusting the compiler rather
than trying to force its hand.

So just nuke our craziness.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1455043788-28112-1-git-send-email-eblake@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agovl: fix migration from prelaunch state
Paolo Bonzini [Mon, 15 Feb 2016 18:40:04 +0000 (19:40 +0100)]
vl: fix migration from prelaunch state

Reproducer is simply to migrate a virtual machine that was started with -S,
or that was already migrated.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agovl: change QEMU state machine for system reset
Denis V. Lunev [Sat, 13 Feb 2016 13:26:26 +0000 (16:26 +0300)]
vl: change QEMU state machine for system reset

This patch implements proposal from Paolo to handle system reset when
the guest is not running.

"After a reset, main_loop_should_exit should actually transition
to VM_STATE_PRELAUNCH (*not* RUN_STATE_PAUSED) for *all* states except
RUN_STATE_INMIGRATE, RUN_STATE_SAVE_VM (which I think cannot happen
there) and (of course) RUN_STATE_RUNNING."

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1455369986-20353-1-git-send-email-den@openvz.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agobuild: Don't redefine 'inline'
Eric Blake [Tue, 9 Feb 2016 18:49:48 +0000 (11:49 -0700)]
build: Don't redefine 'inline'

Actively redefining 'inline' is wrong for C++, where gcc has an
extension 'inline namespace' which fails to compile if the
keyword 'inline' is replaced by a macro expansion.  This will
matter once we start to include "qemu/osdep.h" first from C++
files, depending also on whether the system headers are new
enough to be using the gcc extension.

But rather than just guard things by __cplusplus, let's look at
the overall picture.  Commit df2542c737ea2 in 2007 defined 'inline'
to the gcc attribute __always_inline__, with the rationale "To
avoid discarded inlining bug".  But compilers have improved since
then, and we are probably better off trusting the compiler rather
than trying to force its hand.

So just nuke our craziness.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1455043788-28112-1-git-send-email-eblake@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agochar: fix handling of QIO_CHANNEL_ERR_BLOCK
Daniel P. Berrange [Fri, 12 Feb 2016 14:46:50 +0000 (14:46 +0000)]
char: fix handling of QIO_CHANNEL_ERR_BLOCK

If io_channel_send_full gets QIO_CHANNEL_ERR_BLOCK it
and has already sent some of the data, it should return
that amount of data, not EAGAIN, as that would cause
the caller to re-try already sent data.

Unfortunately due to a previous rebase conflict resolution
error, the code for dealing with this was in the wrong
part of the conditional, and so mistakenly ran on other
I/O errors.

This be seen running

   qemu-system-x86_64 -monitor stdio

and entering 'info mtree', when running on a slow console
(eg a slow remote ssh session). The monitor would get into
an indefinite loop writing the same data until it managed
to send it all without getting EAGAIN.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455288410-27046-1-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoRevert "qemu-char: Keep pty slave file descriptor open until the master is closed"
Paolo Bonzini [Fri, 12 Feb 2016 15:05:10 +0000 (16:05 +0100)]
Revert "qemu-char: Keep pty slave file descriptor open until the master is closed"

This reverts commit 34689e206abddac87a5217d458534e24f2a05562.

Marc-André Lureau provided the following commentary: "It looks like if
a the slave is opened, then Linux will buffer the master writes, up to
a few kb and then throttle, so it's not entirely blocked but eventually
the guest VM dies.  However, not having any slave open it will simply let
the write go and discard the data.  At least, virt-install configures
a pty for the serial but viewers like virt-manager do not necessarily
open it.  And, if there are no viewers, it will just hang.  If qemu
starts reading all the data from the slave, I don't think interactions
with other slaves will work. I don't see much options but to close the
slave, thus reverting this patch."

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agocheckpatch: Eliminate false positive in case of space before square bracket in a...
Leonid Bloch [Thu, 29 Oct 2015 09:48:38 +0000 (11:48 +0200)]
checkpatch: Eliminate false positive in case of space before square bracket in a definition

Now, macro definition such as "#define abc(x) [x] = y" should pass
without an error.

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Message-Id: <1446112118-12376-3-git-send-email-leonid@daynix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agocheckpatch: Eliminate false positive in case of comma-space-square bracket
Leonid Bloch [Thu, 29 Oct 2015 09:48:37 +0000 (11:48 +0200)]
checkpatch: Eliminate false positive in case of comma-space-square bracket

Previously, an error was printed in cases such as:
{ [1] = 5, [2] = 6 }
The space passed OK after a curly brace, but not after a comma.
Now, a space before a square bracket is allowed, if a comma comes before
it.

Signed-off-by: Leonid Bloch <leonid@daynix.com>
Message-Id: <1446112118-12376-2-git-send-email-leonid@daynix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoio: convert QIOChannelBuffer to use uint8_t instead of char
Daniel P. Berrange [Fri, 12 Feb 2016 16:45:31 +0000 (16:45 +0000)]
io: convert QIOChannelBuffer to use uint8_t instead of char

The QIOChannelBuffer struct uses a 'char *' for its data
buffer. It will give simpler type compatibility with the
migration APIs if it uses 'uint8_t *' instead, avoiding
several casts.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoio: introduce helper for creating channels from file descriptors
Daniel P. Berrange [Wed, 3 Feb 2016 14:00:28 +0000 (14:00 +0000)]
io: introduce helper for creating channels from file descriptors

Depending on what object a file descriptor refers to a different
type of IO channel will be needed - either a QIOChannelFile or
a QIOChannelSocket. Introduce a qio_channel_new_fd() method
which will return the appropriate channel implementation.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoio: improve docs for QIOChannelSocket async functions
Daniel P. Berrange [Wed, 3 Feb 2016 13:47:36 +0000 (13:47 +0000)]
io: improve docs for QIOChannelSocket async functions

In the docs for qio_channel_socket_connect_async,
qio_channel_socket_listen_async and
qio_channel_socket_dgram_async, mention that the
SocketAddress parameters are copied, so can be freed
immediately.

Reviewed-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-i386-20160215' into staging
Peter Maydell [Mon, 15 Feb 2016 11:45:11 +0000 (11:45 +0000)]
Merge remote-tracking branch 'remotes/rth/tags/pull-i386-20160215' into staging

Add XSAVE, MPX, FSGSBASE.

# gpg: Signature made Mon 15 Feb 2016 11:21:50 GMT using RSA key ID 4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"

* remotes/rth/tags/pull-i386-20160215:
  target-i386: Implement FSGSBASE
  target-i386: Enable CR4/XCR0 features for user-mode
  target-i386: Clear bndregs during legacy near jumps
  target-i386: Implement BNDLDX, BNDSTX
  target-i386: Update BNDSTATUS for exceptions raised by BOUND
  target-i386: Implement BNDCL, BNDCU, BNDCN
  target-i386: Implement BNDMOV
  target-i386: Implement BNDMK
  target-i386: Split up gen_lea_modrm
  target-i386: Perform set/reset_inhibit_irq inline
  target-i386: Enable control registers for MPX
  target-i386: Implement XSAVEOPT
  target-i386: Add XSAVE extension
  target-i386: Rearrange processing of 0F AE
  target-i386: Rearrange processing of 0F 01
  target-i386: Split fxsave/fxrstor implementation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotarget-i386: Implement FSGSBASE
Richard Henderson [Wed, 18 Nov 2015 11:55:47 +0000 (12:55 +0100)]
target-i386: Implement FSGSBASE

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Enable CR4/XCR0 features for user-mode
Richard Henderson [Tue, 7 Jul 2015 15:13:10 +0000 (16:13 +0100)]
target-i386: Enable CR4/XCR0 features for user-mode

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Clear bndregs during legacy near jumps
Richard Henderson [Tue, 7 Jul 2015 13:38:58 +0000 (14:38 +0100)]
target-i386: Clear bndregs during legacy near jumps

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Implement BNDLDX, BNDSTX
Richard Henderson [Tue, 7 Jul 2015 13:08:41 +0000 (14:08 +0100)]
target-i386: Implement BNDLDX, BNDSTX

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Update BNDSTATUS for exceptions raised by BOUND
Richard Henderson [Mon, 6 Jul 2015 18:37:40 +0000 (19:37 +0100)]
target-i386: Update BNDSTATUS for exceptions raised by BOUND

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Implement BNDCL, BNDCU, BNDCN
Richard Henderson [Mon, 6 Jul 2015 18:37:00 +0000 (19:37 +0100)]
target-i386: Implement BNDCL, BNDCU, BNDCN

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Implement BNDMOV
Richard Henderson [Mon, 6 Jul 2015 18:10:23 +0000 (19:10 +0100)]
target-i386: Implement BNDMOV

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Implement BNDMK
Richard Henderson [Thu, 9 Jul 2015 07:22:46 +0000 (08:22 +0100)]
target-i386: Implement BNDMK

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Split up gen_lea_modrm
Richard Henderson [Thu, 9 Jul 2015 07:22:01 +0000 (08:22 +0100)]
target-i386: Split up gen_lea_modrm

This is immediately usable by lea and multi-byte nop,
and will be required to implement parts of the mpx spec.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Perform set/reset_inhibit_irq inline
Richard Henderson [Mon, 6 Jul 2015 16:29:59 +0000 (17:29 +0100)]
target-i386: Perform set/reset_inhibit_irq inline

With helpers that can be reused for other things.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Enable control registers for MPX
Richard Henderson [Thu, 2 Jul 2015 14:57:14 +0000 (15:57 +0100)]
target-i386: Enable control registers for MPX

Enable and disable at CPL changes, MSR changes, and XRSTOR changes.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Implement XSAVEOPT
Richard Henderson [Thu, 2 Jul 2015 14:21:23 +0000 (15:21 +0100)]
target-i386: Implement XSAVEOPT

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Add XSAVE extension
Richard Henderson [Thu, 2 Jul 2015 13:53:40 +0000 (14:53 +0100)]
target-i386: Add XSAVE extension

This includes XSAVE, XRSTOR, XGETBV, XSETBV, which are all related,
as well as the associate cpuid bits.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Rearrange processing of 0F AE
Richard Henderson [Tue, 17 Nov 2015 14:08:57 +0000 (15:08 +0100)]
target-i386: Rearrange processing of 0F AE

Rather than nesting tests of OP, MOD, and RM, decode them all at once
with a switch.  Also, add some missing #UD checks for e.g. incorrect
LOCK prefix.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Rearrange processing of 0F 01
Richard Henderson [Thu, 2 Jul 2015 12:59:21 +0000 (13:59 +0100)]
target-i386: Rearrange processing of 0F 01

Rather than nesting tests of OP, MOD, and RM, decode them
all at once with a switch.  Fixes incorrect decoding of
AMD Pacifica extensions (aka vmrun et al) via op==2 path.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agotarget-i386: Split fxsave/fxrstor implementation
Richard Henderson [Wed, 1 Jul 2015 12:01:50 +0000 (13:01 +0100)]
target-i386: Split fxsave/fxrstor implementation

We will be able to reuse these pieces for XSAVE/XRSTOR.

Signed-off-by: Richard Henderson <rth@twiddle.net>
8 years agoMerge remote-tracking branch 'remotes/sstabellini/tags/xen-2016-02-12' into staging
Peter Maydell [Fri, 12 Feb 2016 17:36:12 +0000 (17:36 +0000)]
Merge remote-tracking branch 'remotes/sstabellini/tags/xen-2016-02-12' into staging

Xen 2016-02-12

# gpg: Signature made Fri 12 Feb 2016 17:28:09 GMT using RSA key ID 70E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"

* remotes/sstabellini/tags/xen-2016-02-12:
  xen: Drop __XEN_LATEST_INTERFACE_VERSION__ checks from prior to Xen 4.2
  xen: move xenforeignmemory compat layer into common place
  xen: drop XenXC and associated interface wrappers
  xen: drop xen_xc_hvm_inject_msi wrapper
  xen: drop support for Xen 4.1 and older.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2016-02-11' into...
Peter Maydell [Thu, 11 Feb 2016 15:09:33 +0000 (15:09 +0000)]
Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2016-02-11' into staging

trivial patches for 2016-02-11

# gpg: Signature made Thu 11 Feb 2016 12:16:04 GMT using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"

* remotes/mjt/tags/pull-trivial-patches-2016-02-11:
  w32: include winsock2.h before windows.h
  Adds keycode 86 to the hid_usage_keys translation table.
  s390x: remove s390-zipl.rom
  Passthru CCID card: QOMify
  Emulated CCID card: QOMify
  ES1370: QOMify
  char: fix parameter name / type in BSD codepath
  qmp-spec: fix index in doc
  rdma: remove check on time_spent when calculating mbs
  qemu-sockets: simplify error handling
  cpu: cpu_save/cpu_load is no more
  qom: Correct object_property_get_int() description
  man: virtfs-proxy-helper: Rework awkward sentence
  remove libtool support

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging
Peter Maydell [Thu, 11 Feb 2016 13:02:28 +0000 (13:02 +0000)]
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging

# gpg: Signature made Wed 10 Feb 2016 19:23:29 GMT using RSA key ID AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"

* remotes/jnsnow/tags/ide-pull-request:
  ahci: prohibit "restarting" the FIS or CLB engines
  ahci: explicitly reject bad engine states on post_load
  ahci: handle LIST_ON and FIS_ON in map helpers
  ahci: Do not unmap NULL addresses
  fdc: always compile-check debug prints
  ide: fix device_reset to not ignore pending AIO
  ide: Add silent DRQ cancellation
  ide: replace blk_drain_all by blk_drain
  ide: move buffered DMA cancel to core
  ide: code motion
  ide: Prohibit RESET on IDE drives

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agow32: include winsock2.h before windows.h
Paolo Bonzini [Tue, 9 Feb 2016 14:16:57 +0000 (15:16 +0100)]
w32: include winsock2.h before windows.h

Recent Fedora complains while compiling ui/sdl.c:

    /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]

And with this patch we dutifully obey.

Stefan Weil:

Without that patch, windows.h will include winsock.h
(which conflicts with winsock2.h) when compiling sdl.c.

Normally we define WIN32_LEAN_AND_MEAN, and
windows.h won't include winsock.h.

include/ui/sdl2.h and ui/sdl.c undefine that macro,
so the order of the include files is important.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoAdds keycode 86 to the hid_usage_keys translation table.
Daniel Serpell [Thu, 4 Feb 2016 19:03:40 +0000 (16:03 -0300)]
Adds keycode 86 to the hid_usage_keys translation table.

This key is present in international keyboards, between left shift and
the 'Z' key, ant is described in the HID usage tables as "Keyboard
Non-US \ and |": http://www.usb.org/developers/hidpage/Hut1_12v2.pdf

This patch fixes the usb-kbd devices.

Signed-off-by: Daniel Serpell <daniel.serpell@gmail.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agos390x: remove s390-zipl.rom
Michael Tokarev [Wed, 10 Feb 2016 11:02:44 +0000 (14:02 +0300)]
s390x: remove s390-zipl.rom

This is an s390 boot rom which was used in s390-virtio machine.
but since commit 3538fb6f89dd9bb2e7e59de2bfad52a45321c744
"s390x: remove s390-virtio machine", this file isn't used.
The only place it is referenced in the code is an unused
define ZIPL_FILENAME.  There's also comment in hw/s390/ipl.c
which I'm modifying too, to refer to s390-ccw.img instead.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
8 years agoPassthru CCID card: QOMify
Cao jin [Wed, 3 Feb 2016 02:36:35 +0000 (10:36 +0800)]
Passthru CCID card: QOMify

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoEmulated CCID card: QOMify
Cao jin [Wed, 3 Feb 2016 02:36:34 +0000 (10:36 +0800)]
Emulated CCID card: QOMify

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoES1370: QOMify
Cao jin [Mon, 1 Feb 2016 07:57:35 +0000 (15:57 +0800)]
ES1370: QOMify

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agochar: fix parameter name / type in BSD codepath
Daniel P. Berrange [Fri, 22 Jan 2016 17:35:25 +0000 (17:35 +0000)]
char: fix parameter name / type in BSD codepath

The BSD impl of qemu_chr_open_pp_fd had mis-declared
its parameter type as ChardevBackend instead of
ChardevCommon. It had also mistakenly used the variable
name 'common' instead of 'backend'.

Tested-by: Sean Bruno <sbruno@freebsd.org>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoqmp-spec: fix index in doc
Wei Yang [Sun, 24 Jan 2016 14:09:58 +0000 (14:09 +0000)]
qmp-spec: fix index in doc

The index is duplicated. Just change it.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agordma: remove check on time_spent when calculating mbs
Wei Yang [Sun, 24 Jan 2016 14:09:57 +0000 (14:09 +0000)]
rdma: remove check on time_spent when calculating mbs

Within the if statement, time_spent is assured to be non-zero.

This patch just removes the check on time_spent when calculating mbs.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoqemu-sockets: simplify error handling
Paolo Bonzini [Fri, 22 Jan 2016 11:28:33 +0000 (12:28 +0100)]
qemu-sockets: simplify error handling

Just go always through the err label.  (Noticed because Coverity
complains that peer is always non-NULL in the error cleanup code,
but removing the "if" is arguably more prone to introducing the
opposite bug in the future).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agocpu: cpu_save/cpu_load is no more
Paolo Bonzini [Tue, 19 Jan 2016 12:08:28 +0000 (13:08 +0100)]
cpu: cpu_save/cpu_load is no more

Everything has been converted to vmstate.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoqom: Correct object_property_get_int() description
Alistair Francis [Mon, 18 Jan 2016 18:42:01 +0000 (10:42 -0800)]
qom: Correct object_property_get_int() description

The description of object_property_get_int() stated that on an error
it returns NULL. This is not the case and the function will return -1
if an error occurs. Update the commented documentation accordingly.

Reported-By: Christian Liebhardt <christian.liebhardt@keysight.com>
Signed-off-by: Christian Liebhardt <christian.liebhardt@keysight.com>
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoman: virtfs-proxy-helper: Rework awkward sentence
Christophe Fergeau [Mon, 18 Jan 2016 09:51:19 +0000 (10:51 +0100)]
man: virtfs-proxy-helper: Rework awkward sentence

There was a 'capbilities' typo in this man page. This commit
reformulates the sentence the typo was in to make it easier to grasp.
This is based on a suggestion from Eric Blake.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
8 years agoremove libtool support
Michael Tokarev [Wed, 27 Jan 2016 11:36:43 +0000 (14:36 +0300)]
remove libtool support

Libtool support was needed to build shared library for libcacard.
Now there's no need to use libtool, and since the build system is
already complicated enough, we have a way to slightly de-complicate
it.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
8 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20160211' into...
Peter Maydell [Thu, 11 Feb 2016 11:24:16 +0000 (11:24 +0000)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20160211' into staging

target-arm queue:
 * fix some missing traps for EL3 support
 * enable EL3 on Cortex-A53 and Cortex-A57
 * fix syndrome IL bit for Thumb coprocessor, VFP and Neon traps
 * fix mishandling of architectural watchpoints
 * avoid buffer overflow in sd.c
 * fix max-cpus check in virt board
 * implement 'get board revision' query for BCM2835

# gpg: Signature made Thu 11 Feb 2016 11:23:47 GMT using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>"
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"

* remotes/pmaydell/tags/pull-target-arm-20160211:
  bcm2835_property: implement "get board revision" query
  hw/arm/virt: fix max-cpus check
  sd: limit 'req.cmd' while using as an array index
  target-arm: Implement checking of fired watchpoint
  cpu: Add callback to check architectural watchpoint match
  target-arm: Fix IL bit reported for Thumb VFP and Neon traps
  target-arm: Fix IL bit reported for Thumb coprocessor traps
  target-arm: Correct misleading 'is_thumb' syn_* parameter names
  target-arm: Enable EL3 for Cortex-A53 and Cortex-A57
  target-arm: Implement NSACR trapping behaviour
  target-arm: Add isread parameter to CPAccessFns
  target-arm: Update arm_generate_debug_exceptions() to handle EL2/EL3
  target-arm: Use access_trap_aa32s_el1() for SCR and MVBAR
  target-arm: Implement MDCR_EL3 and SDCR
  target-arm: Fix typo in comment in arm_is_secure_below_el3()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agobcm2835_property: implement "get board revision" query
Stephen Warren [Thu, 11 Feb 2016 11:17:32 +0000 (11:17 +0000)]
bcm2835_property: implement "get board revision" query

Return a valid value from the BCM2835 property mailbox query "get board
revision". This query is used by U-Boot. Implementing it fixes the first
obvious difference between qemu and real HW.

The value returned is currently hard-coded to match the RPi2 I own. Other
values are legal, e.g. different board manufacturer field values are
likely to exist in the wild.

Cc: Andrew Baumann <Andrew.Baumann@microsoft.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Message-id: 1454993910-24077-1-git-send-email-swarren@wwwdotorg.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agohw/arm/virt: fix max-cpus check
Andrew Jones [Thu, 11 Feb 2016 11:17:32 +0000 (11:17 +0000)]
hw/arm/virt: fix max-cpus check

mach-virt doesn't yet support hotplug, but command lines specifying
-smp <num>,maxcpus=<bigger-num> don't fail. Of course specifying
bigger-num as something bigger than the machine supports, e.g. > 8
on a gicv2 machine, should fail though. This fix also makes mach-
virt's max-cpus check truly consistent with the one in vl.c:main,
as the one there was already correctly checking max-cpus instead
of smp-cpus.

Reported-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
Message-id: 1454511578-24863-1-git-send-email-drjones@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agosd: limit 'req.cmd' while using as an array index
Prasad J Pandit [Thu, 11 Feb 2016 11:17:32 +0000 (11:17 +0000)]
sd: limit 'req.cmd' while using as an array index

While processing standard SD commands, the 'req.cmd' value could
lead to OOB read when used as an index into 'sd_cmd_type' or
'sd_cmd_class' arrays. Limit 'req.cmd' value to avoid such an
access.

Reported-by: Qinghao Tang <luodalongde@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1453315857-1352-1-git-send-email-ppandit@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotarget-arm: Implement checking of fired watchpoint
Sergey Fedorov [Thu, 11 Feb 2016 11:17:32 +0000 (11:17 +0000)]
target-arm: Implement checking of fired watchpoint

ARM stops before access to a location covered by watchpoint. Also, QEMU
watchpoint fire is not necessarily an architectural watchpoint match.
Unfortunately, that is hardly possible to ignore a fired watchpoint in
debug exception handler. So move watchpoint check from debug exception
handler to the dedicated watchpoint checking callback.

Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1454256948-10485-3-git-send-email-serge.fdrv@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agocpu: Add callback to check architectural watchpoint match
Sergey Fedorov [Thu, 11 Feb 2016 11:17:32 +0000 (11:17 +0000)]
cpu: Add callback to check architectural watchpoint match

When QEMU watchpoint matches, that is not definitely an architectural
watchpoint match yet. If it is a stop-before-access watchpoint then that
is hardly possible to ignore it after throwing a TCG exception.

A special callback is introduced to check for architectural watchpoint
match before raising a TCG exception.

Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454256948-10485-2-git-send-email-serge.fdrv@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agotarget-arm: Fix IL bit reported for Thumb VFP and Neon traps
Peter Maydell [Thu, 11 Feb 2016 11:17:32 +0000 (11:17 +0000)]
target-arm: Fix IL bit reported for Thumb VFP and Neon traps

All Thumb Neon and VFP instructions are 32 bits, so the IL
bit in the syndrome register should be set. Pass false to the
syn_* function's is_16bit argument rather than s->thumb
so we report the correct IL bit.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454683067-16001-4-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Fix IL bit reported for Thumb coprocessor traps
Peter Maydell [Thu, 11 Feb 2016 11:17:31 +0000 (11:17 +0000)]
target-arm: Fix IL bit reported for Thumb coprocessor traps

All Thumb coprocessor instructions are 32 bits, so the IL
bit in the syndrome register should be set. Pass false to the
syn_* function's is_16bit argument rather than s->thumb
so we report the correct IL bit.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454683067-16001-3-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Correct misleading 'is_thumb' syn_* parameter names
Peter Maydell [Thu, 11 Feb 2016 11:17:31 +0000 (11:17 +0000)]
target-arm: Correct misleading 'is_thumb' syn_* parameter names

In syndrome register values, the IL bit indicates the instruction
length, and is 1 for 4-byte instructions and 0 for 2-byte
instructions. All A64 and A32 instructions are 4-byte, but
Thumb instructions may be either 2 or 4 bytes long. Unfortunately
we named the parameter to the syn_* functions for constructing
syndromes "is_thumb", which falsely implies that it should be
set for all Thumb instructions, rather than only the 16-bit ones.
Fix the functions to name the parameter 'is_16bit' instead.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454683067-16001-2-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Enable EL3 for Cortex-A53 and Cortex-A57
Peter Maydell [Thu, 11 Feb 2016 11:17:31 +0000 (11:17 +0000)]
target-arm: Enable EL3 for Cortex-A53 and Cortex-A57

Enable EL3 support for our Cortex-A53 and Cortex-A57 CPU models.
We have enough implemented now to be able to run real world code
at least to some extent (I can boot ARM Trusted Firmware to the
point where it pulls in OP-TEE and then falls over because it
doesn't have a UEFI image it can chain to).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454506721-11843-8-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Implement NSACR trapping behaviour
Peter Maydell [Thu, 11 Feb 2016 11:17:31 +0000 (11:17 +0000)]
target-arm: Implement NSACR trapping behaviour

Implement some corner cases of the behaviour of the NSACR
register on ARMv8:
 * if EL3 is AArch64 then accessing the NSACR from Secure EL1
   with AArch32 should trap to EL3
 * if EL3 is not present or is AArch64 then reads from NS EL1 and
   NS EL2 return constant 0xc00

It would in theory be possible to implement all these with
a single reginfo definition, but for clarity we use three
separate definitions for the three cases and install the
right one based on the CPU feature flags.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1454506721-11843-7-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Add isread parameter to CPAccessFns
Peter Maydell [Thu, 11 Feb 2016 11:17:31 +0000 (11:17 +0000)]
target-arm: Add isread parameter to CPAccessFns

System registers might have access requirements which need to
be described via a CPAccessFn and which differ for reads and
writes. For this to be possible we need to pass the access
function a parameter to tell it whether the access being checked
is a read or a write.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454506721-11843-6-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Update arm_generate_debug_exceptions() to handle EL2/EL3
Peter Maydell [Thu, 11 Feb 2016 11:17:30 +0000 (11:17 +0000)]
target-arm: Update arm_generate_debug_exceptions() to handle EL2/EL3

The arm_generate_debug_exceptions() function as originally implemented
assumes no EL2 or EL3. Since we now have much more of an implementation
of those now, fix this assumption.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454506721-11843-5-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Use access_trap_aa32s_el1() for SCR and MVBAR
Peter Maydell [Thu, 11 Feb 2016 11:17:30 +0000 (11:17 +0000)]
target-arm: Use access_trap_aa32s_el1() for SCR and MVBAR

The registers MVBAR and SCR should have the behaviour of trapping to
EL3 if accessed from Secure EL1, but we were incorrectly implementing
them to UNDEF (which would trap to EL1).  Fix this by using the new
access_trap_aa32s_el1() access function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1454506721-11843-4-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Implement MDCR_EL3 and SDCR
Peter Maydell [Thu, 11 Feb 2016 11:17:30 +0000 (11:17 +0000)]
target-arm: Implement MDCR_EL3 and SDCR

Implement the MDCR_EL3 register (which is SDCR for AArch32).
For the moment we implement it as reads-as-written.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1454506721-11843-3-git-send-email-peter.maydell@linaro.org

8 years agotarget-arm: Fix typo in comment in arm_is_secure_below_el3()
Peter Maydell [Thu, 11 Feb 2016 11:17:30 +0000 (11:17 +0000)]
target-arm: Fix typo in comment in arm_is_secure_below_el3()

Fix a typo where "EL2" was written but "EL3" intended.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1454506721-11843-2-git-send-email-peter.maydell@linaro.org

8 years agomemory: fix usage of find_next_bit and find_next_zero_bit
Paolo Bonzini [Wed, 10 Feb 2016 14:11:45 +0000 (15:11 +0100)]
memory: fix usage of find_next_bit and find_next_zero_bit

The last two arguments to these functions are the last and first bit to
check relative to the base.  The code was using incorrectly the first
bit and the number of bits.  Fix this in cpu_physical_memory_get_dirty
and cpu_physical_memory_all_dirty.  This requires a few changes in the
iteration; change the code in cpu_physical_memory_set_dirty_range to
match.

Fixes: 5b82b70
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Leon Alrae <leon.alrae@imgtec.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-id: 1455113505-11237-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoahci: prohibit "restarting" the FIS or CLB engines
John Snow [Wed, 10 Feb 2016 18:29:40 +0000 (13:29 -0500)]
ahci: prohibit "restarting" the FIS or CLB engines

If the FIS or DMA engines are already started, do not allow them to be
"restarted." As a side-effect of this change, the migration post-load
routine must be modified to cope. If the engines are listed as "on"
in the migrated registers, they must be cleared to allow the startup
routine to see the transition from "off" to "on".

As a second side-effect, the extra argument to ahci_cond_engine_start
is removed in favor of consistent behavior.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1454103689-13042-5-git-send-email-jsnow@redhat.com