]> Git Repo - qemu.git/log
qemu.git
10 years agox86: Use common variable range MTRR counts
Alex Williamson [Thu, 14 Aug 2014 21:39:27 +0000 (15:39 -0600)]
x86: Use common variable range MTRR counts

We currently define the number of variable range MTRR registers as 8
in the CPUX86State structure and vmstate, but use MSR_MTRRcap_VCNT
(also 8) to report to guests the number available.  Change this to
use MSR_MTRRcap_VCNT consistently.

Signed-off-by: Alex Williamson <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agotarget-i386: Don't forbid NX bit on PAE PDEs and PTEs
William Grant [Sun, 24 Aug 2014 05:13:48 +0000 (15:13 +1000)]
target-i386: Don't forbid NX bit on PAE PDEs and PTEs

Commit e8f6d00c30ed88910d0d985f4b2bf41654172ceb ("target-i386: raise
page fault for reserved physical address bits") added a check that the
NX bit is not set on PAE PDPEs, but it also added it to rsvd_mask for
the rest of the function. This caused any PDEs or PTEs with NX set to be
erroneously rejected, making PAE guests with NX support unusable.

Signed-off-by: William Grant <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agoMerge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-08-24' into staging
Peter Maydell [Mon, 25 Aug 2014 16:34:30 +0000 (17:34 +0100)]
Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-08-24' into staging

trivial patches for 2014-08-24

# gpg: Signature made Sun 24 Aug 2014 14:28:49 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <[email protected]>"
# gpg:                 aka "Michael Tokarev <[email protected]>"
# gpg:                 aka "Michael Tokarev <[email protected]>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514  66A7 BEE5 9D74 A4C3 D7DB

* remotes/mjt/tags/trivial-patches-2014-08-24:
  vmxnet3: Pad short frames to minimum size (60 bytes)
  libdecnumber: Fix warnings from smatch (missing static, boolean operations)
  linux-user: fix file descriptor leaks
  po: Fix Makefile rules for in-tree builds without configuration
  slirp/misc: Use the GLib memory allocation APIs
  configure: no need to mkdir QMP
  dma: axidma: Variablise repeated s->streams[i] sub-expr
  microblaze: ml605: Get rid of ddr_base variable
  tests/bios-tables-test: check the value returned by fopen()
  tcg: dump op count into qemu log
  util/path: Use the GLib memory allocation routines

Signed-off-by: Peter Maydell <[email protected]>
10 years agospapr: Add support for new NMI interface
Alexey Kardashevskiy [Wed, 20 Aug 2014 12:16:36 +0000 (22:16 +1000)]
spapr: Add support for new NMI interface

This implements an NMI interface POWERPC SPAPR machine.
This enables an "nmi" HMP/QMP command supported on SPAPR.

This calls POWERPC_EXCP_RESET (vector 0x100) in the guest to deliver NMI
to every CPU. The expected result is XMON (in-kernel debugger) invocation.

Signed-off-by: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agos390x: Migrate to new NMI interface
Alexey Kardashevskiy [Wed, 20 Aug 2014 12:16:35 +0000 (22:16 +1000)]
s390x: Migrate to new NMI interface

This implements an NMI interface for s390 and s390-ccw machines.

This removes #ifdef s390 branch in qmp_inject_nmi so new s390's
nmi_monitor_handler() callback is going to be used for NMI.

Since nmi_monitor_handler()-calling code is platform independent,
CPUState::cpu_index is used instead of S390CPU::env.cpu_num.
There should not be any change in behaviour as both @cpu_index and
@cpu_num are global CPU numbers.

Note that s390_cpu_restart() already takes care of the specified cpu,
so we don't need to schedule via async_run_on_cpu().

Since the only error s390_cpu_restart() can return is ENOSYS, convert
it to QERR_UNSUPPORTED.

Signed-off-by: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agos390x: Convert QEMUMachine to MachineClass
Alexey Kardashevskiy [Wed, 20 Aug 2014 12:16:34 +0000 (22:16 +1000)]
s390x: Convert QEMUMachine to MachineClass

This converts s390-virtio and s390-ccw-virtio machines to QOM MachineClass.
This brings ability to add interfaces to the machine classes. The first
interface for addition will be NMI.

The patch is mechanical so no change in behavior is expected.

Signed-off-by: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agocpus: Define callback for QEMU "nmi" command
Alexey Kardashevskiy [Wed, 20 Aug 2014 12:16:33 +0000 (22:16 +1000)]
cpus: Define callback for QEMU "nmi" command

This introduces an NMI (Non Maskable Interrupt) interface with
a single nmi_monitor_handler() method. A machine or a device can
implement it. This searches for an QOM object with this interface
and if it is implemented, calls it. The callback implements an action
required to cause debug crash dump on in-kernel debugger invocation.
The callback returns Error**.

This adds a nmi_monitor_handle() helper which walks through
all objects to find the interface. The interface method is called
for all found instances.

This adds support for it in qmp_inject_nmi(). Since no architecture
supports it at the moment, there is no change in behaviour.

This changes inject-nmi command description for HMP and QMP.

Signed-off-by: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agopcie: fix trailing whitespace
Michael S. Tsirkin [Sun, 24 Aug 2014 20:45:29 +0000 (22:45 +0200)]
pcie: fix trailing whitespace

Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agoioh3420: Enable ARI forwarding
Knut Omang [Sun, 24 Aug 2014 13:32:20 +0000 (15:32 +0200)]
ioh3420: Enable ARI forwarding

Signed-off-by: Knut Omang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agoioh3420: Remove obsoleted, unused ioh3420_init function
Knut Omang [Sun, 24 Aug 2014 13:32:19 +0000 (15:32 +0200)]
ioh3420: Remove obsoleted, unused ioh3420_init function

Signed-off-by: Knut Omang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agopcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*
Knut Omang [Sun, 24 Aug 2014 13:32:18 +0000 (15:32 +0200)]
pcie: Rename the pcie_cap_ari_* functions to pcie_cap_arifwd_*

Rename helper functions to make a clearer distinction between
the PCIe capability/control register feature ARI forwarding and a
device that supports the ARI feature via an ARI extended PCIe capability.

Signed-off-by: Knut Omang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agopcie: Fix incorrect write to the ari capability next function field
Knut Omang [Sun, 24 Aug 2014 13:32:17 +0000 (15:32 +0200)]
pcie: Fix incorrect write to the ari capability next function field

PCI_ARI_CAP_NFN, a macro for reading next function was used instead of
the intended write.

Signed-off-by: Knut Omang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agossdt-tpm: add generated hex file to git
Michael S. Tsirkin [Wed, 20 Aug 2014 21:20:13 +0000 (23:20 +0200)]
ssdt-tpm: add generated hex file to git

Needed for systems without IASL.

Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agoAdd ACPI tables for TPM
Stefan Berger [Mon, 11 Aug 2014 20:33:36 +0000 (16:33 -0400)]
Add ACPI tables for TPM

Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.

The latter follows this spec here:

http://www.trustedcomputinggroup.org/files/static_page_files/DCD4188E-1A4B-B294-D050A155FB6F7385/TCG_ACPIGeneralSpecification_PublicReview.pdf

This patch has Michael Tsirkin's patches folded in.

Signed-off-by: Stefan Berger <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
10 years agopc: reserve more memory for ACPI for new machine types
Michael S. Tsirkin [Wed, 20 Aug 2014 19:58:12 +0000 (21:58 +0200)]
pc: reserve more memory for ACPI for new machine types

commit 868270f23d8db2cce83e4f082fe75e8625a5fbf9
    acpi-build: tweak acpi migration limits
broke kernel loading with -kernel/-initrd: it doubled
the size of ACPI tables but did not reserve
enough memory.

As a result, issues on boot and halt are observed.

Fix this up by doubling reserved memory for new machine types.

Cc: [email protected]
Reported-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agopcihp: fix possible array out of bounds
Gonglei [Wed, 20 Aug 2014 05:52:30 +0000 (13:52 +0800)]
pcihp: fix possible array out of bounds

Prevent out-of-bounds array access on
acpi_pcihp_pci_status.

Signed-off-by: Gonglei <[email protected]>
Reviewed-by: Peter Crosthwaite <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Cc: [email protected]
Reviewed-by: Marcel Apfelbaum <[email protected]>
10 years agopci_bridge: manually destroy memory regions within PCIBridgeWindows
Paolo Bonzini [Wed, 20 Aug 2014 15:50:05 +0000 (17:50 +0200)]
pci_bridge: manually destroy memory regions within PCIBridgeWindows

The regions are destroyed and recreated on configuration space accesses.
We need to destroy them before the containing PCIBridgeWindows object
is freed.

Reported-by: Gonglei <[email protected]>
Reported-by: Knut Omang <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agovmxnet3: Pad short frames to minimum size (60 bytes)
Ben Draper [Wed, 20 Aug 2014 12:27:14 +0000 (13:27 +0100)]
vmxnet3: Pad short frames to minimum size (60 bytes)

When running VMware ESXi under qemu-kvm the guest discards frames
that are too short. Short ARP Requests will be dropped, this prevents
guests on the same bridge as VMware ESXi from communicating. This patch
simply adds the padding on the network device itself.

Signed-off-by: Ben Draper <[email protected]>
Reviewed-by: Dmitry Fleytman <[email protected]>
Cc: [email protected]
Signed-off-by: Michael Tokarev <[email protected]>
10 years agolibdecnumber: Fix warnings from smatch (missing static, boolean operations)
Stefan Weil [Wed, 20 Aug 2014 09:02:10 +0000 (11:02 +0200)]
libdecnumber: Fix warnings from smatch (missing static, boolean operations)

Signed-off-by: Stefan Weil <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agolinux-user: fix file descriptor leaks
zhanghailiang [Fri, 22 Aug 2014 08:23:51 +0000 (16:23 +0800)]
linux-user: fix file descriptor leaks

Handle variable "fd_orig" going out of scope leaks the handle.

Signed-off-by: zhanghailiang <[email protected]>
Reviewed-by: Gonglei <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agopo: Fix Makefile rules for in-tree builds without configuration
Stefan Weil [Fri, 18 Jul 2014 14:52:29 +0000 (16:52 +0200)]
po: Fix Makefile rules for in-tree builds without configuration

Adding 'update' to the phony targets fixes this error:

$ LANG=C make -C po update
make: Entering directory `/qemu/po'
  LINK  update
/qemu/po/de_DE.po: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [update] Error 1
make: Leaving directory `/qemu/po'

Some other phony targets (build, install) were also added, and the
existing .PHONY statement was moved to a more prominent position at
the beginning of the Makefile.

The patch also fixes a 2nd bug. The default target should be 'all',
but instead 'modules' (from rules.mak) was the default. Fix this by
adding 'all' as a target before any include statement.

Signed-off-by: Stefan Weil <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agoslirp/misc: Use the GLib memory allocation APIs
zhanghailiang [Tue, 19 Aug 2014 08:30:17 +0000 (16:30 +0800)]
slirp/misc: Use the GLib memory allocation APIs

Here we don't check the return value of malloc() which may fail.
Use the g_new() instead, which will abort the program when
there is not enough memory.

Also, use g_strdup instead of strdup and remove the unnecessary
strdup function.

Signed-off-by: zhanghailiang <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Benoît Canet <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agoconfigure: no need to mkdir QMP
Liming Wang [Tue, 19 Aug 2014 02:24:05 +0000 (10:24 +0800)]
configure: no need to mkdir QMP

commit 7537fe04 QMP: QMP/ -> docs/qmp/

Above commit has moved last QMP files to docs/qmp and it's not necessary
to create QMP directory. So remove it from configure.

Signed-off-by: Liming Wang <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agodma: axidma: Variablise repeated s->streams[i] sub-expr
Peter Crosthwaite [Mon, 18 Aug 2014 00:53:12 +0000 (17:53 -0700)]
dma: axidma: Variablise repeated s->streams[i] sub-expr

This have 6 inline usages. Make it a bit more readable by using a local
variable.

Signed-off-by: Peter Crosthwaite <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agomicroblaze: ml605: Get rid of ddr_base variable
Peter Crosthwaite [Mon, 18 Aug 2014 00:52:38 +0000 (17:52 -0700)]
microblaze: ml605: Get rid of ddr_base variable

It's a constant based on a macro. Just use the macro in place.

Signed-off-by: Peter Crosthwaite <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agotests/bios-tables-test: check the value returned by fopen()
zhanghailiang [Mon, 18 Aug 2014 07:54:33 +0000 (15:54 +0800)]
tests/bios-tables-test: check the value returned by fopen()

The function fopen() may fail, so check its return value.

Signed-off-by: zhanghailiang <[email protected]>
Signed-off-by: Li Liu <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agotcg: dump op count into qemu log
zhanghailiang [Mon, 18 Aug 2014 07:58:08 +0000 (15:58 +0800)]
tcg: dump op count into qemu log

fopen() may fail and it does not check its return vaule here,
it is better to dump op count to the normal log file.

Signed-off-by: Li Liu <[email protected]>
Signed-off-by: zhanghailiang <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agoutil/path: Use the GLib memory allocation routines
zhanghailiang [Mon, 18 Aug 2014 07:49:22 +0000 (15:49 +0800)]
util/path: Use the GLib memory allocation routines

In this file, we don't check the return value of malloc/strdup/realloc which may fail.
Instead of using these routines, we use the GLib memory APIs g_malloc/g_strdup/g_realloc.
They will exit on allocation failure, so there is no need to test for failure,
which would be fine for setup.

Signed-off-by: zhanghailiang <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
10 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Fri, 22 Aug 2014 15:12:51 +0000 (16:12 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block patches

# gpg: Signature made Fri 22 Aug 2014 14:47:53 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <[email protected]>"

* remotes/kevin/tags/for-upstream: (29 commits)
  qemu-img: Allow cache mode specification for amend
  qemu-img: Allow source cache mode specification
  vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  blkdebug: Delete BH in bdrv_aio_cancel
  qemu-iotests: add test case 101 for short file I/O
  raw-posix: fix O_DIRECT short reads
  block/iscsi: fix memory corruption on iscsi resize
  block/vvfat.c: remove debugging code to reinit stderr if NULL
  iotests: Add test for image filename construction
  quorum: Implement bdrv_refresh_filename()
  nbd: Implement bdrv_refresh_filename()
  blkverify: Implement bdrv_refresh_filename()
  blkdebug: Implement bdrv_refresh_filename()
  block: Add bdrv_refresh_filename()
  virtio-blk: fix reference a pointer which might be freed
  virtio-blk: allow block_resize with dataplane
  block: acquire AioContext in qmp_block_resize()
  qemu-iotests: Fix 028 reference output for qed
  test-coroutine: test cost introduced by coroutine
  iotests: Add test for qcow2's cache options
  ...

Signed-off-by: Peter Maydell <[email protected]>
10 years agoMerge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging
Peter Maydell [Fri, 22 Aug 2014 13:39:53 +0000 (14:39 +0100)]
Merge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging

* remotes/riku/linux-user-for-upstream: (22 commits)
  linux-user: check return value of malloc()
  linux-user: writev Partial Writes
  linux-user: Support target-to-host translation of mlockall argument
  linux-user: clock_nanosleep errno Handling on PPC
  linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2
  linux-user: Move get_ppc64_abi
  linux-user: Detect fault in sched_rr_get_interval
  linux-user: Handle NULL sched_param argument to sched_*
  linux-user: Detect Negative Message Sizes in msgsnd System Call
  linux-user: Conditionally Pass Attribute Pointer to mq_open()
  linux-user: Make ipc syscall's third argument an abi_long
  linux-user: Properly Handle semun Structure In Cross-Endian Situations
  linux-user: Dereference Pointer Argument to ipc/semctl Sys Call
  linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2
  linux-user: add setns and unshare
  linux-user: support ioprio_{get, set} syscalls
  linux-user: support timerfd_{create, gettime, settime} syscalls
  linux-user: fix readlink handling with magic exe symlink
  linux-user: Fix conversion of sigevent argument to timer_create
  linux-user: Fix syscall instruction usermode emulation on X86_64
  ...

Signed-off-by: Peter Maydell <[email protected]>
10 years agoqemu-img: Allow cache mode specification for amend
Max Reitz [Tue, 22 Jul 2014 20:58:43 +0000 (22:58 +0200)]
qemu-img: Allow cache mode specification for amend

qemu-img amend may extensively modify the target image, depending on the
options to be amended (e.g. conversion to qcow2 compat level 0.10 from
1.1 for an image with many unallocated zero clusters). Therefore it
makes sense to allow the user to specify the cache mode to be used.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqemu-img: Allow source cache mode specification
Max Reitz [Tue, 22 Jul 2014 20:58:42 +0000 (22:58 +0200)]
qemu-img: Allow source cache mode specification

Many qemu-img subcommands only read the source file(s) once. For these
use cases, a full write-back cache is unnecessary and mainly clutters
host cache memory. Though this is generally no concern as cache memory
is freely available and can be scaled by the host OS, it may become a
concern with thin provisioning.

For these cases, it makes sense to allow users to freely specify the
source cache mode (e.g. use no cache at all).

This commit adds a new switch (-T) for the qemu-img subcommands check,
compare, convert and rebase to specify the cache to be used for source
images (the backing file in case of rebase).

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agolinux-user: check return value of malloc()
zhanghailiang [Thu, 14 Aug 2014 07:29:18 +0000 (15:29 +0800)]
linux-user: check return value of malloc()

Signed-off-by: zhanghailiang <[email protected]>
Acked-by: Riku Voipio <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: writev Partial Writes
Tom Musta [Tue, 12 Aug 2014 18:53:43 +0000 (13:53 -0500)]
linux-user: writev Partial Writes

Although not technically not required by POSIX, the writev system call will
typically write out its buffers individually.  That is, if the first buffer
is written successfully, but the second buffer pointer is invalid, then
the first chuck will be written and its size is returned.

Signed-off-by: Tom Musta <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Support target-to-host translation of mlockall argument
Tom Musta [Tue, 12 Aug 2014 18:53:42 +0000 (13:53 -0500)]
linux-user: Support target-to-host translation of mlockall argument

The argument to the mlockall system call is not necessarily the same on
all platforms and thus may require translation prior to passing to the
host.

For example, PowerPC 64 bit platforms define values for MCL_CURRENT
(0x2000) and MCL_FUTURE (0x4000) which are different from Intel platforms
(0x1 and 0x2, respectively)

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: clock_nanosleep errno Handling on PPC
Tom Musta [Tue, 12 Aug 2014 18:53:41 +0000 (13:53 -0500)]
linux-user: clock_nanosleep errno Handling on PPC

The clock_nanosleep syscall is unusual in that it returns positive
numbers in error handling situations, versus returning -1 and setting
errno, or returning a negative errno value.  On POWER, the kernel will
set the SO bit of CR0 to indicate failure in a syscall.  QEMU has
generic handling to do this for syscalls with standard return values.

Add special case code for clock_nanosleep to handle CR0 properly.

Signed-off-by: Tom Musta <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2
Tom Musta [Tue, 12 Aug 2014 18:53:40 +0000 (13:53 -0500)]
linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2

The ELF V2 ABI for PPC64 defines MINSIGSTKSZ as 4096 bytes whereas it was
2048 previously.

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Move get_ppc64_abi
Tom Musta [Wed, 13 Aug 2014 19:04:44 +0000 (14:04 -0500)]
linux-user: Move get_ppc64_abi

The get_ppc64_abi is used to determine the ELF ABI (i.e. V1 or V2). This
routine is currently implemented in the linux-user/elfload.c file but
is useful in other scenarios.  Move the routine to a more generally
available location (linux-user/ppc/target_cpu.h).

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Detect fault in sched_rr_get_interval
Tom Musta [Tue, 12 Aug 2014 18:53:39 +0000 (13:53 -0500)]
linux-user: Detect fault in sched_rr_get_interval

Properly detect a fault when attempting to store into an invalid
struct timespec pointer.

Signed-off-by: Tom Musta <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Handle NULL sched_param argument to sched_*
Tom Musta [Tue, 12 Aug 2014 18:53:38 +0000 (13:53 -0500)]
linux-user: Handle NULL sched_param argument to sched_*

The sched_getparam, sched_setparam and sched_setscheduler system
calls take a pointer argument to a sched_param structure.  When
this pointer is null, errno should be set to EINVAL.

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Detect Negative Message Sizes in msgsnd System Call
Tom Musta [Tue, 12 Aug 2014 18:53:37 +0000 (13:53 -0500)]
linux-user: Detect Negative Message Sizes in msgsnd System Call

The msgsnd system call takes an argument that describes the message
size (msgsz) and is of type size_t.  The system call should set
errno to EINVAL in the event that a negative message size is passed.

Signed-off-by: Tom Musta <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Conditionally Pass Attribute Pointer to mq_open()
Tom Musta [Tue, 12 Aug 2014 18:53:36 +0000 (13:53 -0500)]
linux-user: Conditionally Pass Attribute Pointer to mq_open()

The mq_open system call takes an optional struct mq_attr pointer
argument in the fourth position.  This pointer is used when O_CREAT
is specified in the flags (second) argument.  It may be NULL, in
which case the queue is created with implementation defined attributes.

Change the code to properly handle the case when NULL is passed in the
arg4 position.

Signed-off-by: Tom Musta <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Make ipc syscall's third argument an abi_long
Tom Musta [Tue, 12 Aug 2014 18:53:35 +0000 (13:53 -0500)]
linux-user: Make ipc syscall's third argument an abi_long

For those target ABIs that use the ipc system call (e.g. POWER),
the third argument is used in the shmat path as a pointer.  It
therefore must be declared as an abi_long (versus int) so that
the address bits are not lost in truncation.  In fact, all arguments
to do_ipc should be declared as abit_long.

In fact, it makes more sense for all of the arguments to be declaried
as abi_long (except call).

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Properly Handle semun Structure In Cross-Endian Situations
Tom Musta [Tue, 12 Aug 2014 18:53:34 +0000 (13:53 -0500)]
linux-user: Properly Handle semun Structure In Cross-Endian Situations

The semun union used in the semctl system call contains both an int (val) and
pointers.  In cross-endian situations on 64 bit targets, the value passed to
semctl is an 8 byte (abi_long) value and thus does not have the 4-byte val
field in the correct location.  In order to rectify this, the other half
of the union must be accessed.  This is achieved in code by performing
a byte swap on the entire 8 byte union, followed by a 4-byte swap of the
first half.

Also, eliminate an extraneous (dead) line of code that sets target_su.val in
the IPC_SET/IPC_GET case.

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Dereference Pointer Argument to ipc/semctl Sys Call
Tom Musta [Tue, 12 Aug 2014 18:53:33 +0000 (13:53 -0500)]
linux-user: Dereference Pointer Argument to ipc/semctl Sys Call

When the ipc system call is used to wrap a semctl system call,
the ptr argument to ipc needs to be dereferenced prior to passing
it to the semctl handler.  This is because the fourth argument to
semctl is a union and not a pointer to a union.

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2
Tom Musta [Tue, 12 Aug 2014 18:53:32 +0000 (13:53 -0500)]
linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2

The 64 bit PowerPC platforms eliminate the _unused1 and _unused2
elements of the semid_ds structure from <sys/sem.h>.  So eliminate
these from the target_semid_ds structure.

Signed-off-by: Tom Musta <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: add setns and unshare
Riku Voipio [Tue, 12 Aug 2014 12:58:57 +0000 (15:58 +0300)]
linux-user: add setns and unshare

Add support for the setns and unshare syscalls, trivially passed through to
the host. Based on patches by Paul Burton, added configure check.

Signed-off-by: Paul Burton <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: support ioprio_{get, set} syscalls
Paul Burton [Sun, 22 Jun 2014 10:25:43 +0000 (11:25 +0100)]
linux-user: support ioprio_{get, set} syscalls

Add support for the ioprio_get & ioprio_set syscalls, allowing their
use by target programs.

Signed-off-by: Paul Burton <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: support timerfd_{create, gettime, settime} syscalls
Riku Voipio [Sun, 22 Jun 2014 10:25:42 +0000 (11:25 +0100)]
linux-user: support timerfd_{create, gettime, settime} syscalls

Adds support for the timerfd_create, timerfd_gettime & timerfd_settime
syscalls, allowing use of timerfds by target programs.

v2: By Riku - added configure check for timerfd and ifdefs
for benefit of old distributions like RHEL5.

Signed-off-by: Paul Burton <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: fix readlink handling with magic exe symlink
Mike Frysinger [Fri, 8 Aug 2014 00:40:25 +0000 (09:40 +0900)]
linux-user: fix readlink handling with magic exe symlink

The current code always returns the length of the path when it should
be returning the number of bytes it wrote to the output string.

Further, readlink is not supposed to append a NUL byte, but the current
snprintf logic will always do just that.

Even further, if you pass in a length of 0, you're suppoesd to get back
an error (EINVAL), but the current logic just returns 0.

Further still, if there was an error reading the symlink, we should not
go ahead and try to read the target buffer as it is garbage.

Simple test for the first two issues:
$ cat test.c
int main() {
    char buf[50];
    size_t len;
    for (len = 0; len < 10; ++len) {
        memset(buf, '!', sizeof(buf));
        ssize_t ret = readlink("/proc/self/exe", buf, len);
        buf[20] = '\0';
        printf("readlink(/proc/self/exe, {%s}, %zu) = %zi\n", buf, len, ret);
    }
    return 0;
}

Now compare the output of the native:
$ gcc test.c -o /tmp/x
$ /tmp/x
$ strace /tmp/x

With what qemu does:
$ armv7a-cros-linux-gnueabi-gcc test.c -o /tmp/x -static
$ qemu-arm /tmp/x
$ qemu-arm -strace /tmp/x

Signed-off-by: Mike Frysinger <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Fix conversion of sigevent argument to timer_create
Peter Maydell [Sat, 9 Aug 2014 14:42:32 +0000 (15:42 +0100)]
linux-user: Fix conversion of sigevent argument to timer_create

There were a number of bugs in the conversion of the sigevent
argument to timer_create from target to host format:
 * signal number not converted from target to host
 * thread ID not copied across
 * sigev_value not copied across
 * we never unlocked the struct when we were done

Between them, these problems meant that SIGEV_THREAD_ID
timers (and the glibc-implemented SIGEV_THREAD timers which
depend on them) didn't work.

Fix these problems and clean up the code a little by pulling
the struct conversion out into its own function, in line with
how we convert various other structs. This allows the test
program in bug LP:1042388 to run.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: Fix syscall instruction usermode emulation on X86_64
Jincheng Miao [Fri, 8 Aug 2014 03:56:54 +0000 (11:56 +0800)]
linux-user: Fix syscall instruction usermode emulation on X86_64

Currently syscall instruction is buggy on user mode X86_64,
the EIP is updated after do_syscall(), that is too late for
clone(). Because clone() will create a thread at the env->EIP
(the address of syscall insn), and then child thread enters
do_syscall() again, that is not expected. Sometimes it is tragic.

User mode syscall insn emulation is not used MSR, so the
action should be same to INT 0x80. INT 0x80 will update EIP in
do_interrupt(), ditto for syscall() for consistency.

Signed-off-by: Jincheng Miao <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: redirect openat calls
Riku Voipio [Wed, 6 Aug 2014 07:36:37 +0000 (10:36 +0300)]
linux-user: redirect openat calls

While Mikhail fixed /proc/self/maps, it was noticed openat calls are
not redirected currently. Some archs don't have open at all, so
openat needs to be redirected.

Fix this by consolidating open/openat code to do_openat - open
is implemented using openat(AT_FDCWD, ... ), which according
to open(2) man page is identical.

Since all targets now have openat, remove the ifdef around sys_openat
and openat: case in do_syscall.

Cc: Mikhail Ilin <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agolinux-user: /proc/self/maps content
Mikhail Ilyin [Tue, 5 Aug 2014 13:33:51 +0000 (17:33 +0400)]
linux-user: /proc/self/maps content

Build /proc/self/maps doing a match against guest memory translation table.
Output only that map records which are valid for guest memory layout.

Signed-off-by: Mikhail Ilyin <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
10 years agovmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
Markus Armbruster [Thu, 21 Aug 2014 12:36:19 +0000 (14:36 +0200)]
vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted

Instead of bdrv_getlength().

Commit 57322b7 did this all over block, but one more bdrv_getlength()
has crept in since.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Reviewed-by: Benoît Canet <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblkdebug: Delete BH in bdrv_aio_cancel
Fam Zheng [Fri, 22 Aug 2014 04:45:50 +0000 (12:45 +0800)]
blkdebug: Delete BH in bdrv_aio_cancel

Otherwise error_callback_bh will access the already released acb.

Cc: [email protected]
Signed-off-by: Fam Zheng <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqemu-iotests: add test case 101 for short file I/O
Stefan Hajnoczi [Thu, 21 Aug 2014 12:44:08 +0000 (13:44 +0100)]
qemu-iotests: add test case 101 for short file I/O

Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoraw-posix: fix O_DIRECT short reads
Stefan Hajnoczi [Thu, 21 Aug 2014 12:44:07 +0000 (13:44 +0100)]
raw-posix: fix O_DIRECT short reads

The following O_DIRECT read from a <512 byte file fails:

  $ truncate -s 320 test.img
  $ qemu-io -n -c 'read -P 0 0 512' test.img
  qemu-io: can't open device test.img: Could not read image for determining its format: Invalid argument

Note that qemu-io completes successfully without the -n (O_DIRECT)
option.

This patch fixes qemu-iotests ./check -nocache -vmdk 059.

Cc: [email protected]
Suggested-by: Kevin Wolf <[email protected]>
Reported-by: Markus Armbruster <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblock/iscsi: fix memory corruption on iscsi resize
Peter Lieven [Fri, 22 Aug 2014 08:08:49 +0000 (10:08 +0200)]
block/iscsi: fix memory corruption on iscsi resize

bs->total_sectors is not yet updated at this point. resulting
in memory corruption if the volume has grown and data is written
to the newly availble areas.

CC: [email protected]
Signed-off-by: Peter Lieven <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoMerge remote-tracking branch 'remotes/otubo/seccomp' into staging
Peter Maydell [Thu, 21 Aug 2014 11:48:44 +0000 (12:48 +0100)]
Merge remote-tracking branch 'remotes/otubo/seccomp' into staging

* remotes/otubo/seccomp:
  seccomp: add semctl() to the syscall whitelist

Signed-off-by: Peter Maydell <[email protected]>
10 years agoblock/vvfat.c: remove debugging code to reinit stderr if NULL
Michael Tokarev [Wed, 20 Aug 2014 15:02:38 +0000 (19:02 +0400)]
block/vvfat.c: remove debugging code to reinit stderr if NULL

Just log to stderr unconditionally, like other similar code does.

Signed-off-by: Michael Tokarev <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoseccomp: add semctl() to the syscall whitelist
Paul Moore [Thu, 14 Aug 2014 17:19:32 +0000 (13:19 -0400)]
seccomp: add semctl() to the syscall whitelist

QEMU needs to call semctl() for correct operation.  This particular
problem was identified on shutdown with the following commandline:

 # qemu -sandbox on -monitor stdio \
   -device intel-hda -device hda-duplex -vnc :0

Signed-off-by: Paul Moore <[email protected]>
Signed-off-by: Eduardo Otubo <[email protected]>
10 years agohostmem: set MPOL_MF_MOVE
Michael S. Tsirkin [Wed, 13 Aug 2014 11:50:24 +0000 (13:50 +0200)]
hostmem: set MPOL_MF_MOVE

When memory is allocated on a wrong node, MPOL_MF_STRICT
doesn't move it - it just fails the allocation.
A simple way to reproduce the failure is with mlock=on
realtime feature.

The code comment actually says: "ensure policy won't be ignored"
so setting MPOL_MF_MOVE seems like a better way to do this.

Cc: [email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
10 years agokvm: run cpu state synchronization on target vcpu thread
David Hildenbrand [Wed, 20 Aug 2014 12:55:25 +0000 (14:55 +0200)]
kvm: run cpu state synchronization on target vcpu thread

As already done for kvm_cpu_synchronize_state(), let's trigger
kvm_arch_put_registers() via run_on_cpu() for kvm_cpu_synchronize_post_reset()
and kvm_cpu_synchronize_post_init().

This way, we make sure that the register synchronizing ioctls are
called from the proper vcpu thread; this avoids calls to
synchronize_rcu() in the kernel.

Reviewed-by: Cornelia Huck <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
10 years agoiotests: Add test for image filename construction
Max Reitz [Fri, 18 Jul 2014 18:25:01 +0000 (20:25 +0200)]
iotests: Add test for image filename construction

Testing a real in-use protocol such as NBD is hard; testing blkdebug and
blkverify in its stead is easier and tests basically the same
functionality.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoquorum: Implement bdrv_refresh_filename()
Max Reitz [Fri, 18 Jul 2014 18:25:00 +0000 (20:25 +0200)]
quorum: Implement bdrv_refresh_filename()

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agonbd: Implement bdrv_refresh_filename()
Max Reitz [Fri, 18 Jul 2014 18:24:59 +0000 (20:24 +0200)]
nbd: Implement bdrv_refresh_filename()

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblkverify: Implement bdrv_refresh_filename()
Max Reitz [Fri, 18 Jul 2014 18:24:58 +0000 (20:24 +0200)]
blkverify: Implement bdrv_refresh_filename()

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblkdebug: Implement bdrv_refresh_filename()
Max Reitz [Fri, 18 Jul 2014 18:24:57 +0000 (20:24 +0200)]
blkdebug: Implement bdrv_refresh_filename()

Because blkdebug cannot simply create a configuration file, simply
refuse to reconstruct a plain filename and only generate an options
QDict from the rules instead.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblock: Add bdrv_refresh_filename()
Max Reitz [Fri, 18 Jul 2014 18:24:56 +0000 (20:24 +0200)]
block: Add bdrv_refresh_filename()

Some block devices may not have a filename in their BDS; and for some,
there may not even be a normal filename at all. To work around this, add
a function which tries to construct a valid filename for the
BDS.filename field.

If a filename exists or a block driver is able to reconstruct a valid
filename (which is placed in BDS.exact_filename), this can directly be
used.

If no filename can be constructed, we can still construct an options
QDict which is then converted to a JSON object and prefixed with the
"json:" pseudo protocol prefix. The QDict is placed in
BDS.full_open_options.

For most block drivers, this process can be done automatically; those
that need special handling may define a .bdrv_refresh_filename() method
to fill BDS.exact_filename and BDS.full_open_options themselves.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agovirtio-blk: fix reference a pointer which might be freed
zhanghailiang [Mon, 18 Aug 2014 07:42:50 +0000 (15:42 +0800)]
virtio-blk: fix reference a pointer which might be freed

In function virtio_blk_handle_request, it may freed memory pointed by req,
So do not access member of req after calling this function.

Cc: [email protected]
Reviewed-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: zhanghailiang <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agovirtio-blk: allow block_resize with dataplane
Stefan Hajnoczi [Mon, 18 Aug 2014 13:52:29 +0000 (14:52 +0100)]
virtio-blk: allow block_resize with dataplane

Now that block_resize acquires the AioContext we can safely allow
resizing the disk.

Reported-by: Andrey Korolyov <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblock: acquire AioContext in qmp_block_resize()
Stefan Hajnoczi [Mon, 18 Aug 2014 13:52:28 +0000 (14:52 +0100)]
block: acquire AioContext in qmp_block_resize()

Make block_resize safe for dataplane where another thread may be running
the BlockDriverState's AioContext.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqemu-iotests: Fix 028 reference output for qed
Kevin Wolf [Tue, 19 Aug 2014 17:28:58 +0000 (19:28 +0200)]
qemu-iotests: Fix 028 reference output for qed

We need to filter out driver-specific options in the "Formatting..."
string printed by qemu when creating the backup image.

Reported-by: Peter Wu <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
Tested-by: Peter Wu <[email protected]>
10 years agotest-coroutine: test cost introduced by coroutine
Ming Lei [Wed, 13 Aug 2014 10:08:47 +0000 (18:08 +0800)]
test-coroutine: test cost introduced by coroutine

This test runs dummy function with coroutine by using
two enter and one yield since which is a common usage.

So we can see the cost introduced by corouting for running
one function, for example:

Run operation 20000000 iterations 4.841071 s, 4131K operations/s
242ns per coroutine

Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoiotests: Add test for qcow2's cache options
Max Reitz [Mon, 18 Aug 2014 20:07:34 +0000 (22:07 +0200)]
iotests: Add test for qcow2's cache options

Add a test which tests various combinations of qcow2's cache options
(some of which are valid, some of which are not).

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqcow2: Add runtime options for cache sizes
Max Reitz [Mon, 18 Aug 2014 20:07:33 +0000 (22:07 +0200)]
qcow2: Add runtime options for cache sizes

Add options for specifying the size of the metadata caches. This can
either be done directly for each cache (if only one is given, the other
will be derived according to a default ratio) or combined for both.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqcow2: Use g_try_new0() for cache array
Max Reitz [Mon, 18 Aug 2014 20:07:32 +0000 (22:07 +0200)]
qcow2: Use g_try_new0() for cache array

With a variable cache size, the number given to qcow2_cache_create() may
be huge. Therefore, use g_try_new0().

While at it, use g_new0() instead of g_malloc0() for allocating the
Qcow2Cache object.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqcow2: Constant cache size in bytes
Max Reitz [Mon, 18 Aug 2014 20:07:31 +0000 (22:07 +0200)]
qcow2: Constant cache size in bytes

Specifying the metadata cache sizes in clusters results in less clusters
(and much less bytes) covered for small cluster sizes and vice versa.
Using a constant byte size reduces this difference, and makes it
possible to manually specify the cache size in an easily comprehensible
unit.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agorunner: Kill a program under test by time-out
Maria Kustova [Mon, 18 Aug 2014 20:02:35 +0000 (00:02 +0400)]
runner: Kill a program under test by time-out

If a program under test get frozen, the test should finish and report about its
failure.
In such cases the runner waits for 10 minutes until the program ends its
execution. After this time-out the program will be terminated and the test will
be marked as failed.

For current limitation of test image size to 10 MB as a maximum an execution of
each command takes about several seconds in general, so 10 minutes is enough to
discriminate freeze, but not drastically increase an overall test duration.

Signed-off-by: Maria Kustova <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agorunner: Add an argument for test duration
Maria Kustova [Mon, 18 Aug 2014 20:02:34 +0000 (00:02 +0400)]
runner: Add an argument for test duration

After the specified duration the runner stops executing new tests, but it
doesn't interrupt running ones.

Reviewed-by: Fam Zheng <[email protected]>
Signed-off-by: Maria Kustova <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblock: Drop some superfluous casts from void *
Markus Armbruster [Tue, 19 Aug 2014 08:31:11 +0000 (10:31 +0200)]
block: Drop some superfluous casts from void *

They clutter the code.  Unfortunately, I can't figure out how to make
Coccinelle drop all of them, so I have to settle for common special
cases:

    @@
    type T;
    T *pt;
    void *pv;
    @@
    - pt = (T *)pv;
    + pt = pv;
    @@
    type T;
    @@
    - (T *)
      (\(g_malloc\|g_malloc0\|g_realloc\|g_new\|g_new0\|g_renew\|
 g_try_malloc\|g_try_malloc0\|g_try_realloc\|
 g_try_new\|g_try_new0\|g_try_renew\)(...))

Topped off with minor manual style cleanups.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoqemu-io-cmds: g_renew() can't fail, bury dead error handling
Markus Armbruster [Tue, 19 Aug 2014 08:31:10 +0000 (10:31 +0200)]
qemu-io-cmds: g_renew() can't fail, bury dead error handling

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblock: Use g_new() & friends to avoid multiplying sizes
Markus Armbruster [Tue, 19 Aug 2014 08:31:09 +0000 (10:31 +0200)]
block: Use g_new() & friends to avoid multiplying sizes

g_new(T, n) is safer than g_malloc(sizeof(*v) * n) for two reasons.
One, it catches multiplication overflowing size_t.  Two, it returns
T * rather than void *, which lets the compiler catch more type
errors.

Perhaps a conversion to g_malloc_n() would be neater in places, but
that's merely four years old, and we can't use such newfangled stuff.

This commit only touches allocations with size arguments of the form
sizeof(T), plus two that use 4 instead of sizeof(uint32_t).  We can
make the others safe by converting to g_malloc_n() when it becomes
available to us in a couple of years.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoblock: Use g_new() & friends where that makes obvious sense
Markus Armbruster [Tue, 19 Aug 2014 08:31:08 +0000 (10:31 +0200)]
block: Use g_new() & friends where that makes obvious sense

g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
for two reasons.  One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.

Patch created with Coccinelle, with two manual changes on top:

* Add const to bdrv_iterate_format() to keep the types straight

* Convert the allocation in bdrv_drop_intermediate(), which Coccinelle
  inexplicably misses

Coccinelle semantic patch:

    @@
    type T;
    @@
    -g_malloc(sizeof(T))
    +g_new(T, 1)
    @@
    type T;
    @@
    -g_try_malloc(sizeof(T))
    +g_try_new(T, 1)
    @@
    type T;
    @@
    -g_malloc0(sizeof(T))
    +g_new0(T, 1)
    @@
    type T;
    @@
    -g_try_malloc0(sizeof(T))
    +g_try_new0(T, 1)
    @@
    type T;
    expression n;
    @@
    -g_malloc(sizeof(T) * (n))
    +g_new(T, n)
    @@
    type T;
    expression n;
    @@
    -g_try_malloc(sizeof(T) * (n))
    +g_try_new(T, n)
    @@
    type T;
    expression n;
    @@
    -g_malloc0(sizeof(T) * (n))
    +g_new0(T, n)
    @@
    type T;
    expression n;
    @@
    -g_try_malloc0(sizeof(T) * (n))
    +g_try_new0(T, n)
    @@
    type T;
    expression p, n;
    @@
    -g_realloc(p, sizeof(T) * (n))
    +g_renew(T, p, n)
    @@
    type T;
    expression p, n;
    @@
    -g_try_realloc(p, sizeof(T) * (n))
    +g_try_renew(T, p, n)

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
10 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140819' into...
Peter Maydell [Wed, 20 Aug 2014 08:55:42 +0000 (09:55 +0100)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140819' into staging

target-arm:
 * fix preferred return address for A64 BRK insn
 * implement AArch64 single-stepping
 * support loading gzip compressed AArch64 kernels
 * use correct PSCI function IDs in the DT when KVM uses PSCI 0.2
 * minor cleanups

# gpg: Signature made Tue 19 Aug 2014 19:04:09 BST using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <[email protected]>"

* remotes/pmaydell/tags/pull-target-arm-20140819:
  arm: stellaris: Remove misleading address_space_mem var
  arm: armv7m: Rename address_space_mem -> system_memory
  aarch64: Allow -kernel option to take a gzip-compressed kernel.
  loader: Add load_image_gzipped function.
  arm: cortex-a9: Fix cache-line size and associativity
  arm/virt: Use PSCI v0.2 function IDs in the DT when KVM uses PSCI v0.2
  target-arm: Rename QEMU PSCI v0.1 definitions
  target-arm: Implement MDSCR_EL1 as having state
  target-arm: Implement ARMv8 single-stepping for AArch32 code
  target-arm: Implement ARMv8 single-step handling for A64 code
  target-arm: A64: Avoid duplicate exit_tb(0) in non-linked goto_tb
  target-arm: Set PSTATE.SS correctly on exception return from AArch64
  target-arm: Correctly handle PSTATE.SS when taking exception to AArch32
  target-arm: Don't allow AArch32 to access RES0 CPSR bits
  target-arm: Adjust debug ID registers per-CPU
  target-arm: Provide both 32 and 64 bit versions of debug registers
  target-arm: Allow STATE_BOTH reginfo descriptions for more than cp14
  target-arm: Collect up the debug cp register definitions
  target-arm: Fix return address for A64 BRK instructions

Signed-off-by: Peter Maydell <[email protected]>
10 years agoRevert "memory: Use canonical path component as the name"
Peter Maydell [Tue, 19 Aug 2014 19:05:46 +0000 (20:05 +0100)]
Revert "memory: Use canonical path component as the name"

This reverts commit b0225c2c0d89200a29dc3d0b59d2e87a79cbaeb8
(which breaks building with Xen enabled and also leaks memory).

Signed-off-by: Peter Maydell <[email protected]>
10 years agoarm: stellaris: Remove misleading address_space_mem var
Peter Crosthwaite [Tue, 19 Aug 2014 17:56:28 +0000 (18:56 +0100)]
arm: stellaris: Remove misleading address_space_mem var

It's a MemoryRegion and not an AddressSpace. But since it's single use,
just inline the get_system_memory() call to the only usage to remove it.

Signed-off-by: Peter Crosthwaite <[email protected]>
Message-id: d6914047e10b956514cfaa5f391ef56c7d851b34.1408347860[email protected]
Signed-off-by: Peter Maydell <[email protected]>
10 years agoarm: armv7m: Rename address_space_mem -> system_memory
Peter Crosthwaite [Tue, 19 Aug 2014 17:56:28 +0000 (18:56 +0100)]
arm: armv7m: Rename address_space_mem -> system_memory

This argument is a MemoryRegion and not an AddressSpace.

"Address space" means something quite different to "memory region"
in QEMU parlance so rename the variable to reduce confusion.

Signed-off-by: Peter Crosthwaite <[email protected]>
Message-id: f666cf7f2318d9b461b1e320a45bf0d82da9b7dd.1408347860[email protected]
Signed-off-by: Peter Maydell <[email protected]>
10 years agoaarch64: Allow -kernel option to take a gzip-compressed kernel.
Richard W.M. Jones [Tue, 19 Aug 2014 17:56:28 +0000 (18:56 +0100)]
aarch64: Allow -kernel option to take a gzip-compressed kernel.

On aarch64 it is the bootloader's job to uncompress the kernel.  UEFI
and u-boot bootloaders do this automatically when the kernel is
gzip-compressed.

However the qemu -kernel option does not do this.  The following
command does not work:

  qemu-system-aarch64 [...] -kernel /boot/vmlinuz

because it tries to execute the gzip-compressed data.

This commit lets gzip-compressed kernels be uncompressed
transparently.

Currently this is only done when emulating aarch64.

Signed-off-by: Richard W.M. Jones <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Crosthwaite <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 1407831259[email protected]
Signed-off-by: Peter Maydell <[email protected]>
10 years agoloader: Add load_image_gzipped function.
Richard W.M. Jones [Tue, 19 Aug 2014 17:56:28 +0000 (18:56 +0100)]
loader: Add load_image_gzipped function.

As the name suggests this lets you load a ROM/disk image that is
gzipped.  It is uncompressed before storing it in guest memory.

Signed-off-by: Richard W.M. Jones <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Peter Crosthwaite <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: 1407831259[email protected]
[PMM: removed stray space before ')']
Signed-off-by: Peter Maydell <[email protected]>
10 years agoarm: cortex-a9: Fix cache-line size and associativity
Peter Crosthwaite [Tue, 19 Aug 2014 17:56:27 +0000 (18:56 +0100)]
arm: cortex-a9: Fix cache-line size and associativity

For A9, The cache associativity is 4 and the lines size is 32B.
Self identify in CCSIDR accordingly. Cache size remains at 16k.

QEMU doesn't emulate caches, but we should still report the correct
cache-line size to the guest. Some guests (like u-boot) complain if
the cache-line size mismatches a requested flush or invalidate
operation.

Signed-off-by: Peter Crosthwaite <[email protected]>
Message-id: 1de6bd40155a1d2f2e93e24b1b1d1d677a432641.1408346233[email protected]
Signed-off-by: Peter Maydell <[email protected]>
10 years agoarm/virt: Use PSCI v0.2 function IDs in the DT when KVM uses PSCI v0.2
Christoffer Dall [Tue, 19 Aug 2014 17:56:27 +0000 (18:56 +0100)]
arm/virt: Use PSCI v0.2 function IDs in the DT when KVM uses PSCI v0.2

The current code supplies the PSCI v0.1 function IDs in the DT even when
KVM uses PSCI v0.2.

This will break guest kernels that only support PSCI v0.1 as they will
use the IDs provided in the DT.  Guest kernels with PSCI v0.2 support
are not affected by this patch, because they ignore the function IDs in
the device tree and rely on the architecture definition.

Define QEMU versions of the constants and check that they correspond to
the Linux defines on Linux build hosts.  After this patch, both guest
kernels with PSCI v0.1 support and guest kernels with PSCI v0.2 should
work.

Tested on TC2 for 32-bit and APM Mustang for 64-bit (aarch64 guest
only).  Both cases tested with 3.14 and linus/master and verified I
could bring up 2 cpus with both guest kernels.  Also tested 32-bit with
a 3.14 host kernel with only PSCI v0.1 and both guests booted here as
well.

Cc: [email protected]
Signed-off-by: Christoffer Dall <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
10 years agotarget-arm: Rename QEMU PSCI v0.1 definitions
Christoffer Dall [Tue, 19 Aug 2014 17:56:27 +0000 (18:56 +0100)]
target-arm: Rename QEMU PSCI v0.1 definitions

The function IDs for PSCI v0.1 are exported by KVM and defined as
KVM_PSCI_FN_<something>.  To build using these defines in non-KVM code,
QEMU defines these IDs locally and check their correctness against the
KVM headers when those are available.

However, the naming scheme used for QEMU (almost) clashes with the PSCI
v0.2 definitions from Linux so to avoid unfortunate naming when we
introduce local PSCI v0.2 defines, rename the current local defines with
QEMU_ prependend and clearly identify the PSCI version as v0.1 in the
defines.

Cc: [email protected]
Signed-off-by: Christoffer Dall <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
10 years agotarget-arm: Implement MDSCR_EL1 as having state
Peter Maydell [Tue, 19 Aug 2014 17:56:27 +0000 (18:56 +0100)]
target-arm: Implement MDSCR_EL1 as having state

Now that all the new code to support single-stepping is in
place, wire up the guest-visible MDSCR_EL1, so the guest
can enable single-stepping.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
10 years agotarget-arm: Implement ARMv8 single-stepping for AArch32 code
Peter Maydell [Tue, 19 Aug 2014 17:56:27 +0000 (18:56 +0100)]
target-arm: Implement ARMv8 single-stepping for AArch32 code

ARMv8 single-stepping requires the exception level that controls
the single-stepping to be in AArch64 execution state, but the
code being stepped may be in AArch64 or AArch32. Implement the
necessary support code for single-stepping AArch32 code.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
10 years agotarget-arm: Implement ARMv8 single-step handling for A64 code
Peter Maydell [Tue, 19 Aug 2014 17:56:26 +0000 (18:56 +0100)]
target-arm: Implement ARMv8 single-step handling for A64 code

Implement ARMv8 software single-step handling for A64 code:
correctly update the single-step state machine and generate
debug exceptions when stepping A64 code.

This patch has no behavioural change since MDSCR_EL1.SS can't
be set by the guest yet.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
10 years agotarget-arm: A64: Avoid duplicate exit_tb(0) in non-linked goto_tb
Peter Maydell [Tue, 19 Aug 2014 17:56:26 +0000 (18:56 +0100)]
target-arm: A64: Avoid duplicate exit_tb(0) in non-linked goto_tb

If gen_goto_tb() decides not to link the two TBs, then the
fallback path generates unnecessary code:
 * if singlestep is enabled then we generate unreachable code
   after the gen_exception_internal(EXCP_DEBUG)
 * if singlestep is disabled then we will generate exit_tb(0)
   twice, once in gen_goto_tb() and once coming out of the
   main loop with is_jmp set to DISAS_JUMP

Correct these deficiencies by only emitting exit_tb() in the
non-singlestep case, in which case we can use DISAS_TB_JUMP
to suppress the main-loop exit_tb().

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
10 years agotarget-arm: Set PSTATE.SS correctly on exception return from AArch64
Peter Maydell [Tue, 19 Aug 2014 17:56:26 +0000 (18:56 +0100)]
target-arm: Set PSTATE.SS correctly on exception return from AArch64

Set the PSTATE.SS bit correctly on exception returns from AArch64,
as required by the debug single-step functionality.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
10 years agotarget-arm: Correctly handle PSTATE.SS when taking exception to AArch32
Peter Maydell [Tue, 19 Aug 2014 17:56:26 +0000 (18:56 +0100)]
target-arm: Correctly handle PSTATE.SS when taking exception to AArch32

When an exception is taken to AArch32, we must clear the PSTATE.SS
bit for the exception handler, and must also ensure that the SS bit
is not set in the value saved to SPSR_<mode>. Achieve both of these
aims by clearing the bit in uncached_cpsr before saving it to the SPSR.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
This page took 0.090533 seconds and 4 git commands to generate.