]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
6 years agoqcow: fix memory leaks related to encryption
Daniel P. Berrange [Fri, 14 Jul 2017 10:31:05 +0000 (11:31 +0100)]
qcow: fix memory leaks related to encryption

Fix leak of the 'encryptopts' string, which was mistakenly
declared const.

Fix leak of QemuOpts entry which should not have been deleted
from the opts array.

Reported by: coverity
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20170714103105.5781-1-berrange@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
6 years agohw/display/sm501: Don't use vmstate_register_ram_global()
Peter Maydell [Mon, 17 Jul 2017 16:37:42 +0000 (17:37 +0100)]
hw/display/sm501: Don't use vmstate_register_ram_global()

The sm501 device uses vmstate_register_ram_global() to register its
memory region for migration.  This means it gets a name that is
assumed to be global to the whole system, which in turn means that if
you create two of the device we assert because of the duplication:

qemu-system-ppc -device sm501 -device sm501
RAMBlock "sm501.local" already registered, abort!
Aborted (core dumped)

Changing this to just use memory_region_init_ram()'s automatic
registration of the memory region with a device-local name fixes
this.  The downside is that it breaks migration compatibility, but
luckily we only added migration support to this device in the 2.10
release cycle so we haven't released a QEMU version with the broken
implementation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-id: 1500309462-12792-1-git-send-email-peter.maydell@linaro.org

6 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20170725' into staging
Peter Maydell [Tue, 25 Jul 2017 10:28:58 +0000 (11:28 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20170725' into staging

Various changes for the s390x code:
- updates for cpu model handling
- fix compilation with --disable-tcg
- fixes in vfio-ccw and I/O instruction handling

# gpg: Signature made Tue 25 Jul 2017 10:15:37 BST
# gpg:                using RSA key 0xDECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>"
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20170725:
  s390x/css: fix ilen in IO instruction handlers
  target/s390x: Add remaining switches to compile with --disable-tcg
  target/s390x: Move exception-related functions to a new excp_helper.c file
  target/s390x: Rework program_interrupt() and related functions
  target/s390x: Move diag helpers to a separate file
  target/s390x: Move s390_cpu_dump_state() to helper.c
  target/s390x: improve baselining if certain base features are missing
  s390x/kvm: better comment regarding zPCI feature availability
  target/s390x: introduce (test|set)_be_bit
  target/s390x: indicate query subfunction in s390_fill_feat_block
  target/s390x: drop BE_BIT()
  s390/cpumodel: remove KSS from the default model of z14
  vfio/ccw: fix initialization of the Object DeviceState pointer in the common base-device
  vfio/ccw: allocate irq info with the right size

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170725' into staging
Peter Maydell [Tue, 25 Jul 2017 09:04:39 +0000 (10:04 +0100)]
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170725' into staging

ppc patch queue 2017-07-25

Last pull request for the 2.10 hard freeze, and correspondingly small.
There are a handful of bugfixes here plus an update for the "pseries"
guest firmware (SLOF).

This is later than ideal for a guest firmware update.  However, this
does include a number of fixes in that guest firmware, so I think it's
worth the risk of squeezing this in just before the hard freeze.

# gpg: Signature made Tue 25 Jul 2017 06:43:14 BST
# gpg:                using RSA key 0x6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>"
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>"
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>"
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>"
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dgibson/tags/ppc-for-2.10-20170725:
  pseries: Update SLOF firmware image
  spapr: Fix QEMU abort during memory unplug
  spapr/htab: fix savevm
  spapr_pci: Fix obsolete comment about MSIX encoding in addr/data

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agos390x/css: fix ilen in IO instruction handlers
Halil Pasic [Mon, 24 Jul 2017 14:34:52 +0000 (16:34 +0200)]
s390x/css: fix ilen in IO instruction handlers

When initiating a program check interruption by calling program_interrupt
the instruction length (ilen) of the current instruction is supplied as
the third parameter.

On s390x all the IO instructions are of instruction format S and their
ilen is 4.  The calls to program_interrupt (introduced by commits
7b18aad543 ("s390: Add channel I/O instructions.", 2013-01-24) and
61bf0dcb2e ("s390x/ioinst: Add missing alignment checks for IO
instructions", 2013-06-21)) however use ilen == 2.

This is probably due to a confusion between ilen which specifies the
instruction length in bytes and ILC which does the same but in halfwords.
If kvm_enabled() this does not actually matter, because the ilen
parameter of program_interrupt is effectively unused.

Let's provide the correct ilen to program_interrupt.

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Fixes: 7b18aad543 ("s390: Add channel I/O instructions.")
Fixes: 61bf0dcb2e ("s390x/ioinst: Add missing alignment checks for IO instructions")
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170724143452.55534-1-pasic@linux.vnet.ibm.com>
Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: Add remaining switches to compile with --disable-tcg
Thomas Huth [Mon, 24 Jul 2017 08:52:50 +0000 (10:52 +0200)]
target/s390x: Add remaining switches to compile with --disable-tcg

Adding some CONFIG_TCG tests to be finally able to compile QEMU
on s390x also without TCG.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1500886370-14572-6-git-send-email-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: Move exception-related functions to a new excp_helper.c file
Thomas Huth [Mon, 24 Jul 2017 08:52:49 +0000 (10:52 +0200)]
target/s390x: Move exception-related functions to a new excp_helper.c file

These functions can not be compiled with --disable-tcg. But since we
need the other functions from helper.c in the non-tcg build, we can also
not simply remove helper.c from the non-tcg builds. Thus the problematic
functions have to be moved into a separate new file instead that we
can later omit in the non-tcg builds.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1500886370-14572-5-git-send-email-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: Rework program_interrupt() and related functions
Thomas Huth [Mon, 24 Jul 2017 08:52:48 +0000 (10:52 +0200)]
target/s390x: Rework program_interrupt() and related functions

misc_helper.c won't be compiled with --disable-tcg anymore, but we
still need the program_interrupt() function in that case. Move it
to interrupt.c instead, and refactor it to re-use the code from
trigger_pgm_exception() (for TCG) and enter_pgmcheck() (for KVM,
which now got renamed to kvm_s390_program_interrupt() for
clarity).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1500886370-14572-4-git-send-email-thuth@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: Move diag helpers to a separate file
Thomas Huth [Mon, 24 Jul 2017 08:52:47 +0000 (10:52 +0200)]
target/s390x: Move diag helpers to a separate file

misc_helper.c won't be compiled with --disable-tcg anymore, but we
still need the diag helpers in KVM builds, too, so move the helper
functions to a separate file.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1500886370-14572-3-git-send-email-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: Move s390_cpu_dump_state() to helper.c
Thomas Huth [Mon, 24 Jul 2017 08:52:46 +0000 (10:52 +0200)]
target/s390x: Move s390_cpu_dump_state() to helper.c

translate.c can not be compiled with --disable-tcg, but we need
the s390_cpu_dump_state() in KVM-only builds, too. So let's move
that function to helper.c instead, which will also be compiled
when --disable-tcg has been specified.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1500886370-14572-2-git-send-email-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: improve baselining if certain base features are missing
David Hildenbrand [Thu, 20 Jul 2017 12:37:21 +0000 (14:37 +0200)]
target/s390x: improve baselining if certain base features are missing

There are certain features that we put into base models, but that are
not relevant for the actual search. The most famous example are
MSA subfunctions that might be disabled on certain real hardware out
there.

While the kvm host model detection will usually detect the correct model
on such machines (as it will in the common case not pass features to check
for into s390_find_cpu_def()), baselining will fall back to a quite old
model just because some MSA subfunctions are missing.

Let's improve that by ignoring lack of these features while performing
the search for a base model.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170720123721.12366-6-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agos390x/kvm: better comment regarding zPCI feature availability
David Hildenbrand [Thu, 20 Jul 2017 12:37:20 +0000 (14:37 +0200)]
s390x/kvm: better comment regarding zPCI feature availability

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170720123721.12366-5-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: introduce (test|set)_be_bit
David Hildenbrand [Thu, 20 Jul 2017 12:37:19 +0000 (14:37 +0200)]
target/s390x: introduce (test|set)_be_bit

Using ordinary bitmap operations to set/test bits does not work properly
on architectures !s390x. Let's drop (test|set)_bit_inv and introduce
(test|set)_be_bit instead. These functions work on uint8_t array, not on
unsigned longs arrays and are for now only used in the context of
CPU features.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170720123721.12366-4-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: indicate query subfunction in s390_fill_feat_block
David Hildenbrand [Thu, 20 Jul 2017 12:37:18 +0000 (14:37 +0200)]
target/s390x: indicate query subfunction in s390_fill_feat_block

We'll have to do the same for TCG, so let's just move it in there.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170720123721.12366-3-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agotarget/s390x: drop BE_BIT()
David Hildenbrand [Thu, 20 Jul 2017 12:37:17 +0000 (14:37 +0200)]
target/s390x: drop BE_BIT()

Unused and broken, let's just get rid of it.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170720123721.12366-2-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agos390/cpumodel: remove KSS from the default model of z14
Christian Borntraeger [Thu, 20 Jul 2017 11:27:31 +0000 (13:27 +0200)]
s390/cpumodel: remove KSS from the default model of z14

The SIE_KSS feature will allow a guest to use KSS for a nested guest.
To create a nested guest the SIE_F2 facility is still necessary.
Since SIE_F2 is not part of the default model it does not make
a lot of sense to provide the SIE_KSS feature in the default model.
Let's also create a dependency check.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1500550051-7821-2-git-send-email-borntraeger@de.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agovfio/ccw: fix initialization of the Object DeviceState pointer in the common base...
Dong Jia Shi [Tue, 18 Jul 2017 01:49:26 +0000 (03:49 +0200)]
vfio/ccw: fix initialization of the Object DeviceState pointer in the common base-device

Commit 7da624e2 ("vfio: Test realized when using VFIOGroup.device_list
iterator") introduced a pointer to the Object DeviceState in the VFIO
common base-device and skipped non-realized devices as we iterate
VFIOGroup.device_list. While it missed to initialize the pointer for
the vfio-ccw case. Let's fix it.

Fixes: 7da624e2 ("vfio: Test realized when using VFIOGroup.device_list
                  iterator")

Cc: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <20170718014926.44781-3-bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agovfio/ccw: allocate irq info with the right size
Jing Zhang [Tue, 18 Jul 2017 01:49:25 +0000 (03:49 +0200)]
vfio/ccw: allocate irq info with the right size

When allocating memory for the vfio_irq_info parameter of the
VFIO_DEVICE_GET_IRQ_INFO ioctl, we used the wrong size. Let's
fix it by using the right size.

Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Jing Zhang <bjzhjing@linux.vnet.ibm.com>
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Message-Id: <20170718014926.44781-2-bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6 years agopseries: Update SLOF firmware image
Alexey Kardashevskiy [Mon, 24 Jul 2017 05:22:32 +0000 (15:22 +1000)]
pseries: Update SLOF firmware image

The main changes are:
- fixes in PCI bridges code;
- LUN>255 are allowed not in virtio-scsi.

The full list is:
  > pci-scan: Fix pci-bridge-set-mem-base and pci-bridge-set-mem-limit
  > pci: Avoid 32-bit prefetchable memory area if possible
  > Remove unused functions ishexdigit and $cat-comma
  > pci: Translate PCI addresses to host addresses at the end of map-in
  > Define 'open' and 'close' words of the /aliases nodes right from the start
  > virtio-scsi: Allow LUNs bigger than 255
  > paflof: Silence gcc's -Warray-bounds warning for stack pointers
  > board_qemu: move code out of fdt-fix-node-phandle
  > board_qemu: drop unused values early in fdt-fix-node-phandle
  > pci: Improve the pci-var-out debug function
  > libhvcall: drop unused KVMPPC_H_REPORT_MC_ERR and KVMPPC_H_NMI_MCE defines

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr: Fix QEMU abort during memory unplug
Bharata B Rao [Fri, 21 Jul 2017 04:51:06 +0000 (10:21 +0530)]
spapr: Fix QEMU abort during memory unplug

Commit 0cffce56 (hw/ppc/spapr.c: adding pending_dimm_unplugs to
sPAPRMachineState) introduced a new way to track pending LMBs of DIMM
device that is marked for removal. Since this commit we can hit the
assert in spapr_pending_dimm_unplugs_add() in the following situation:

- DIMM device removal fails as the guest doesn't allow the removal.
- Subsequent attempt to remove the same DIMM would hit the assert
  as the corresponding sPAPRDIMMState is still part of the
  pending_dimm_unplugs list.

Fix this by removing the assert and conditionally adding the
sPAPRDIMMState to pending_dimm_unplugs list only when it is not
already present.

Fixes: 0cffce56ae3501c5783d779f97993ce478acf856
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
[dwg: Tweaked to avoid returning NULL when spapr_pending_dimm_unplugs_add()
 does find an existing entry]
Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr/htab: fix savevm
Laurent Vivier [Tue, 18 Jul 2017 10:16:32 +0000 (12:16 +0200)]
spapr/htab: fix savevm

Commit 3a38429 ("spapr: Add a "no HPT" encoding to HTAB migration stream")
allows to migrate an empty HPT, but doesn't mark correctly the
end of the migration stream.

The end condition (value returned by htab_save_iterate())
should be 1, whereas in 3a38429 it returns 0.

The problem can be reproduced with QEMU monitor command "savevm":
the command never stops and the disk image grows without limit.

Fixes: 3a38429748aa4f74abaecf16c4c087e8a325e12a
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_pci: Fix obsolete comment about MSIX encoding in addr/data
Alexey Kardashevskiy [Tue, 18 Jul 2017 02:00:33 +0000 (12:00 +1000)]
spapr_pci: Fix obsolete comment about MSIX encoding in addr/data

f1c2dc7c866a "spapr-pci: rework MSI/MSIX" (07/2013) changed MSIX encoding
but forgot to change the comment so this changes it.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170724' into...
Peter Maydell [Mon, 24 Jul 2017 17:15:45 +0000 (18:15 +0100)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170724' into staging

target-arm queue:
 * fix a TCG temporary leak in aarch64 rev16
 * fsl_imx*: migrate the ROM contents
 * integratorcp: don't use vmstate_register_ram_global for flash
 * mps2: Correctly set parent bus for SCC device

# gpg: Signature made Mon 24 Jul 2017 18:05:06 BST
# gpg:                using RSA key 0x3C2525ED14360CDE
# 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>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20170724:
  integratorcp: Don't migrate flash using vmstate_register_ram_global()
  mps2: Correctly set parent bus for SCC device
  fsl_imx*: Migrate ROM contents
  target/arm: fix TCG temp leak in aarch64 rev16

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agointegratorcp: Don't migrate flash using vmstate_register_ram_global()
Peter Maydell [Mon, 24 Jul 2017 16:56:12 +0000 (17:56 +0100)]
integratorcp: Don't migrate flash using vmstate_register_ram_global()

Instead of migrating the flash by creating the memory region
with memory_region_init_ram_nomigrate() and then calling
vmstate_register_ram_global(), just use memory_region_init_ram(),
which now handles migration registration automatically.

This is a migration compatibility break for the integratorcp
board, because the RAM region's migration name changes to
include the device path. This is OK because we don't guarantee
migration compatibility for this board.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1500310341-28931-1-git-send-email-peter.maydell@linaro.org

6 years agomps2: Correctly set parent bus for SCC device
Peter Maydell [Mon, 24 Jul 2017 16:56:12 +0000 (17:56 +0100)]
mps2: Correctly set parent bus for SCC device

A cut-and-paste error meant that instead of setting the
qdev parent bus for the SCC device we were setting it
twice for the ARMv7M container device. Fix this bug.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1500634509-28011-1-git-send-email-peter.maydell@linaro.org

6 years agofsl_imx*: Migrate ROM contents
Peter Maydell [Mon, 24 Jul 2017 16:56:12 +0000 (17:56 +0100)]
fsl_imx*: Migrate ROM contents

The fsl-imx* boards accidentally forgot to register the ROM memory
regions for migration.  This used to require a manual step of calling
vmstate_register_ram(), but following commits
1cfe48c1ce21..b08199c6fbea194 we can use memory_region_init_rom() to
have it do the migration for us.

This is a migration break, but the migration code currently does not
handle the case of having two RAM regions which were not registered
for migration, and so prior to this commit a migration load would
always fail with:
  "qemu-system-arm: Length mismatch: 0x4000 in != 0x18000: Invalid argument"

NB: migration appears at this point to be broken for this board
anyway -- it succeeds but the destination hangs; probably some
device in the system does not yet support migration.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1500309775-18361-1-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: fix TCG temp leak in aarch64 rev16
Emilio G. Cota [Mon, 24 Jul 2017 16:56:12 +0000 (17:56 +0100)]
target/arm: fix TCG temp leak in aarch64 rev16

Fix a TCG temporary leak in the new aarch64 rev16 handling.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Mon, 24 Jul 2017 15:58:16 +0000 (16:58 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches for 2.10.0-rc0

# gpg: Signature made Mon 24 Jul 2017 15:16:42 BST
# gpg:                using RSA key 0x7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  qemu-iotests: Avoid unnecessary sleeps
  block: Skip implicit nodes in query-block/blockstats
  qcow2: Fix sector calculation in qcow2_measure()
  dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
  iotests: Remove a few tests from 'quick' group

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-07-24' into staging
Peter Maydell [Mon, 24 Jul 2017 15:20:47 +0000 (16:20 +0100)]
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-07-24' into staging

nbd patches for 2017-07-24

- Eric Blake: [0/2] Update qemu-nbd version

# gpg: Signature made Mon 24 Jul 2017 14:58:23 BST
# gpg:                using RSA key 0xA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg:                 aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2017-07-24:
  maint: Reorder include directives for qemu-{nbd, io}
  qemu-nbd: Update version string

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agomaint: Reorder include directives for qemu-{nbd, io}
Eric Blake [Fri, 21 Jul 2017 13:50:47 +0000 (08:50 -0500)]
maint: Reorder include directives for qemu-{nbd, io}

HACKING recommends listing system includes right after osdep.h,
and before any other in-project headers.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20170721135047.25005-3-eblake@redhat.com>

6 years agoqemu-nbd: Update version string
Eric Blake [Fri, 21 Jul 2017 13:50:46 +0000 (08:50 -0500)]
qemu-nbd: Update version string

qemu-io and qemu-img already mirror the qemu version string,
time to make qemu-nbd do the same.

Reported-by: 陳培泓 <pahome.chen@mirlab.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20170721135047.25005-2-eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
6 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-error-2017-07-24' into staging
Peter Maydell [Mon, 24 Jul 2017 13:34:42 +0000 (14:34 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2017-07-24' into staging

Error reporting patches for 2017-07-24

# gpg: Signature made Mon 24 Jul 2017 13:17:49 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-error-2017-07-24:
  error: Revert unwanted change of warning messages

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoqemu-iotests: Avoid unnecessary sleeps
Kevin Wolf [Fri, 21 Jul 2017 14:41:21 +0000 (16:41 +0200)]
qemu-iotests: Avoid unnecessary sleeps

Test cases 030, 041 and 055 used to sleep for a second after calling
block-job-pause to make sure that the block job had time to actually
get into paused state. We can instead poll its status and use that one
second only as a timeout.

The tests also slept a second for checking that the block jobs don't
make progress while being paused. Half a second is more than enough for
this.

These changes reduce the total time for the three tests by 25 seconds on
my laptop (from 155 seconds to 130).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agoblock: Skip implicit nodes in query-block/blockstats
Kevin Wolf [Tue, 18 Jul 2017 15:24:05 +0000 (17:24 +0200)]
block: Skip implicit nodes in query-block/blockstats

Commits 0db832f and 6cdbceb introduced the automatic insertion of filter
nodes above the top layer of mirror and commit block jobs. The
assumption made there was that since libvirt doesn't do node-level
management of the block layer yet, it shouldn't be affected by added
nodes.

This is true as far as commands issued by libvirt are concerned. It only
uses BlockBackend names to address nodes, so any operations it performs
still operate on the root of the tree as intended.

However, the assumption breaks down when you consider query commands,
which return data for the wrong node now. These commands also return
information on some child nodes (bs->file and/or bs->backing), which
libvirt does make use of, and which refer to the wrong nodes, too.

One of the consequences is that oVirt gets wrong information about the
image size and stops the VM in response as long as a mirror or commit
job is running:

https://bugzilla.redhat.com/show_bug.cgi?id=1470634

This patch fixes the problem by hiding the implicit nodes created
automatically by the mirror and commit block jobs in the output of
query-block and BlockBackend-based query-blockstats as long as the user
doesn't indicate that they are aware of those nodes by providing a node
name for them in the QMP command to start the block job.

The node-based commands query-named-block-nodes and query-blockstats
with query-nodes=true still show all nodes, including implicit ones.
This ensures that users that are capable of node-level management can
still access the full information; users that only know BlockBackends
won't use these commands.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Tested-by: Eric Blake <eblake@redhat.com>
6 years agoqcow2: Fix sector calculation in qcow2_measure()
Eric Blake [Fri, 21 Jul 2017 18:32:43 +0000 (13:32 -0500)]
qcow2: Fix sector calculation in qcow2_measure()

We used MAX() instead of the intended MIN() when computing how many
sectors to view in the current loop iteration of qcow2_measure(),
and passed in a value of INT_MAX sectors instead of our more usual
limit of BDRV_REQUEST_MAX_SECTORS (the latter avoids 32-bit overflow
on conversion to bytes).  For small files, the bug is harmless:
bdrv_get_block_status_above() clamps its *pnum answer to the BDS
size, regardless of any insanely larger input request.  However, for
any file at least 2T in size, we can very easily end up going into an
infinite loop (the maximum of 0x100000000 sectors and INT_MAX is a
64-bit quantity, which becomes 0 when assigned to int; once nb_sectors
is 0, we never make progress).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6 years agodirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
Eric Blake [Fri, 21 Jul 2017 18:32:42 +0000 (13:32 -0500)]
dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented

We've been documenting the value in bytes since its introduction
in commit b9a9b3a4 (v1.3), where it was actually reported in bytes.

Commit e4654d2 (v2.0) then removed things from block/qapi.c, in
preparation for a rewrite to a list of dirty sectors in the next
commit 21b5683 in block.c, but the new code mistakenly started
reporting in sectors.

Fixes: https://bugzilla.redhat.com/1441460
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6 years agoiotests: Remove a few tests from 'quick' group
Eric Blake [Mon, 17 Jul 2017 14:26:20 +0000 (09:26 -0500)]
iotests: Remove a few tests from 'quick' group

A run of './check -qcow2 -g quick' on my machine produced only
two tests that took longer than 5 seconds; 178 took 18, and
189 took 7.  Remove them from the quick group.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
6 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-07-18-v2' into staging
Peter Maydell [Mon, 24 Jul 2017 12:21:33 +0000 (13:21 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-07-18-v2' into staging

QAPI patches for 2017-07-18

# gpg: Signature made Mon 24 Jul 2017 12:40:56 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2017-07-18-v2:
  migration: Use JSON null instead of "" to reset parameter to default
  migration: Unshare MigrationParameters struct for now
  migration: Add TODO comments on duplication of QAPI_CLONE()
  migration: Clean up around tls_creds, tls_hostname
  hmp: Clean up and simplify hmp_migrate_set_parameter()
  block: Use JSON null instead of "" to disable backing file
  tests/test-qobject-input-visitor: Drop redundant test
  qapi: Introduce a first class 'null' type
  qapi: Use QNull for a more regular visit_type_null()
  qapi: Separate type QNull from QObject

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoerror: Revert unwanted change of warning messages
Markus Armbruster [Wed, 19 Jul 2017 07:33:34 +0000 (09:33 +0200)]
error: Revert unwanted change of warning messages

Commit 97f4030 changed warning messages from

    timestamp-if-enabled progname ":" location "warning: " message

to

    "warning: " timestamp-if-enabled progname ":" location message

This regressed qemu-iotests 051.  Put "warning: " right back where it
was, along with "info: ".

Reported-by: Kevin Wolf <kwolf@redhat.com>
Cc: Alistair Francis <alistair.francis@xilinx.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1500449614-16811-1-git-send-email-armbru@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
6 years agoutil: Introduce include/qemu/cpuid.h
Richard Henderson [Wed, 19 Jul 2017 04:40:18 +0000 (18:40 -1000)]
util: Introduce include/qemu/cpuid.h

Clang 3.9 passes the CONFIG_AVX2_OPT configure test.  However, the
supplied <cpuid.h> does not contain the bit_AVX2 define that we use
when detecting whether the routine can be enabled.

Introduce a qemu-specific header that uses the compiler's definition
of __cpuid et al, but supplies any missing bit_* definitions needed.
This avoids introducing any extra ifdefs to util/bufferiszero.c, and
allows quite a few to be removed from tcg/i386/tcg-target.inc.c.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20170719044018.18063-1-rth@twiddle.net
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agomigration: Use JSON null instead of "" to reset parameter to default
Markus Armbruster [Tue, 18 Jul 2017 12:42:04 +0000 (14:42 +0200)]
migration: Use JSON null instead of "" to reset parameter to default

migrate-set-parameters sets migration parameters according to is
arguments like this:

* Present means "set the parameter to this value"

* Absent means "leave the parameter unchanged"

* Except for parameters tls_creds and tls_hostname, "" means "reset
  the parameter to its default value

The first two are perfectly normal: presence of the parameter makes
the command do something.

The third one overloads the parameter with a second meaning.  The
overloading is *implicit*, i.e. it's not visible in the types.  Works
here, because "" is neither a valid TLS credentials ID, nor a valid
host name.

Pressing argument values the schema accepts, but are semantically
invalid, into service to mean "reset to default" is not general, as
suitable invalid values need not exist.  I also find it ugly.

To clean this up, we could add a separate flag argument to ask for
"reset to default", or add a distinct value to @tls_creds and
@tls_hostname.  This commit implements the latter: add JSON null to
the values of @tls_creds and @tls_hostname, deprecate "".

Because we're so close to the 2.10 freeze, implement it in the
stupidest way possible: have qmp_migrate_set_parameters() rewrite null
to "" before anything else can see the null.  The proper way to do it
would be rewriting "" to null, but that requires fixing up code to
work with null.  Add TODO comments for that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agomigration: Unshare MigrationParameters struct for now
Markus Armbruster [Tue, 18 Jul 2017 11:42:11 +0000 (13:42 +0200)]
migration: Unshare MigrationParameters struct for now

Commit de63ab6 "migrate: Share common MigrationParameters struct"
reused MigrationParameters for the arguments of
migrate-set-parameters, with the following rationale:

    It is rather verbose, and slightly error-prone, to repeat
    the same set of parameters for input (migrate-set-parameters)
    as for output (query-migrate-parameters), where the only
    difference is whether the members are optional.  We can just
    document that the optional members will always be present
    on output, and then share a common struct between both
    commands.  The next patch can then reduce the amount of
    code needed on input.

I need to unshare them to correct a design flaw in a stupid, but
minimally invasive way, in the next commit.  We can restore the
sharing when we redo that patch in a less stupid way.  Add a suitable
TODO comment.

Note that I revert only the sharing part of commit de63ab6, not the
part that made the members of query-migrate-parameters' result
optional.  The schema (and thus introspection) remains inaccurate for
query-migrate-parameters.  If we decide not to restore the sharing, we
should revert that part, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agomigration: Add TODO comments on duplication of QAPI_CLONE()
Markus Armbruster [Tue, 18 Jul 2017 10:57:38 +0000 (12:57 +0200)]
migration: Add TODO comments on duplication of QAPI_CLONE()

qmp_query_migrate_parameters() and qmp_migrate_set_parameters()
effectively duplicate QAPI_CLONE() inline.  Add suitable TODO
comments.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agomigration: Clean up around tls_creds, tls_hostname
Markus Armbruster [Tue, 18 Jul 2017 10:04:54 +0000 (12:04 +0200)]
migration: Clean up around tls_creds, tls_hostname

Optional MigrationParameters members tls_creds and tls_hostname can't
actually be absent outside qmp_migrate_set_parameters() since commit
4af245d (v2.9.0).

Note that commit 4af245d reverted the part of commit de63ab6 (v2.8.0)
that made tls_creds and tls_hostname absent instead of "" in the value
of query-migrate-parameters, even though commit de63ab6 called that a
mistake.  What a mess.

Drop the redundant tests for presence, and update documentation.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
6 years agohmp: Clean up and simplify hmp_migrate_set_parameter()
Markus Armbruster [Tue, 18 Jul 2017 09:23:08 +0000 (11:23 +0200)]
hmp: Clean up and simplify hmp_migrate_set_parameter()

The bulk of hmp_migrate_set_parameter()'s code sets one member of
MigrationParameters according to the command's arguments.  It uses a
string visitor for integer and boolean members, but not for string and
size members.  It calls visit_type_bool() right away, but delays
visit_type_int() some.  The delaying requires a flag variable and a
bit of trickery: we set all integer members instead of just the one we
want, and rely on the has_FOOs to mask the unwanted ones.

Clean this up as follows.  Don't delay calling visit_type_int().  Use
the string visitor for strings, too.  This involves extra allocations
and cleanup, but doing them is simpler and cleaner than avoiding them.

Sadly, using the string visitor for sizes isn't possible, because it
defaults to Bytes rather than Mebibytes.  Add a comment explaining
that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agoblock: Use JSON null instead of "" to disable backing file
Markus Armbruster [Tue, 18 Jul 2017 06:54:00 +0000 (08:54 +0200)]
block: Use JSON null instead of "" to disable backing file

BlockdevRef is an alternate of BlockdevOptions (inline definition) and
str (reference to an existing block device by name).  BlockdevRef
value "" is special: "no block device should be referenced."  It's
actually interpreted that way in just one place: optional member
@backing of COW formats.  Semantics:

* Present means "use this block device" as backing storage

* Absent means "default to the one stored in the image"

* Except "" means "don't use backing storage at all"

The first two are perfectly normal: when the parameter is absent, it
defaults to an implied value, but the value's meaning is the same.

The third one overloads the parameter with a second meaning.  The
overloading is *implicit*, i.e. it's not visible in the types.  Works
here, because "" is not a value block device ID.

Pressing argument values the schema accepts, but are semantically
invalid, into service to mean "do something else entirely" is not
general, as suitable invalid values need not exist.  I also find it
ugly.

To clean this up, we could add a separate flag argument to suppress
@backing, or add a distinct value to @backing.  This commit implements
the latter: add JSON null to the values of @backing, deprecate "".

Because we're so close to the 2.10 freeze, implement it in the
stupidest way possible: have qmp_blockdev_add() rewrite null to ""
before anything else can see the null.  Works, because BlockdevRef
occurs only within arguments of blockdev-add.  The proper way to do it
would be rewriting "" to null, preferably in a cleaner way, but that
requires fixing up code to work with null.  Add a TODO comment for
that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agotests/test-qobject-input-visitor: Drop redundant test
Markus Armbruster [Mon, 26 Jun 2017 17:33:51 +0000 (19:33 +0200)]
tests/test-qobject-input-visitor: Drop redundant test

test_visitor_in_alternate() tests UserDefAlternate with inadmissible
input.  test_visitor_in_fail_alternate() does basically the same.
Drop the former, keep the latter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
6 years agoqapi: Introduce a first class 'null' type
Markus Armbruster [Mon, 26 Jun 2017 17:25:14 +0000 (19:25 +0200)]
qapi: Introduce a first class 'null' type

I expect the 'null' type to be useful mostly for members of alternate
types.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqapi: Use QNull for a more regular visit_type_null()
Markus Armbruster [Mon, 26 Jun 2017 16:22:59 +0000 (18:22 +0200)]
qapi: Use QNull for a more regular visit_type_null()

Make visit_type_null() take an @obj argument like its buddies.  This
helps keep the next commit simple.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
6 years agoqapi: Separate type QNull from QObject
Markus Armbruster [Mon, 26 Jun 2017 11:52:24 +0000 (13:52 +0200)]
qapi: Separate type QNull from QObject

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
6 years agoMerge remote-tracking branch 'remotes/sstabellini/tags/xen-20170721-tag' into staging
Peter Maydell [Mon, 24 Jul 2017 09:01:15 +0000 (10:01 +0100)]
Merge remote-tracking branch 'remotes/sstabellini/tags/xen-20170721-tag' into staging

Xen 2017/07/21

# gpg: Signature made Sat 22 Jul 2017 01:43:34 BST
# gpg:                using RSA key 0x894F8F4870E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"
# gpg:                 aka "Stefano Stabellini <sstabellini@kernel.org>"
# Primary key fingerprint: D04E 33AB A51F 67BA 07D3  0AEA 894F 8F48 70E1 AE90

* remotes/sstabellini/tags/xen-20170721-tag:
  xen-mapcache: Fix the bug when overlapping emulated DMA operations may cause inconsistency in guest memory mappings
  xen: fix compilation on 32-bit hosts

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoxen-mapcache: Fix the bug when overlapping emulated DMA operations may cause inconsis...
Alexey G [Sat, 22 Jul 2017 00:34:20 +0000 (17:34 -0700)]
xen-mapcache: Fix the bug when overlapping emulated DMA operations may cause inconsistency in guest memory mappings

Under certain circumstances normal xen-mapcache functioning may be broken
by guest's actions. This may lead to either QEMU performing exit() due to
a caught bad pointer (and with QEMU process gone the guest domain simply
appears hung afterwards) or actual use of the incorrect pointer inside
QEMU address space -- a write to unmapped memory is possible. The bug is
hard to reproduce on a i440 machine as multiple DMA sources are required
(though it's possible in theory, using multiple emulated devices), but can
be reproduced somewhat easily on a Q35 machine using an emulated AHCI
controller -- each NCQ queue command slot may be used as an independent
DMA source ex. using READ FPDMA QUEUED command, so a single storage
device on the AHCI controller port will be enough to produce multiple DMAs
(up to 32). The detailed description of the issue follows.

Xen-mapcache provides an ability to map parts of a guest memory into
QEMU's own address space to work with.

There are two types of cache lookups:
 - translating a guest physical address into a pointer in QEMU's address
   space, mapping a part of guest domain memory if necessary (while trying
   to reduce a number of such (re)mappings to a minimum)
 - translating a QEMU's pointer back to its physical address in guest RAM

These lookups are managed via two linked-lists of structures.
MapCacheEntry is used for forward cache lookups, while MapCacheRev -- for
reverse lookups.

Every guest physical address is broken down into 2 parts:
    address_index  = phys_addr >> MCACHE_BUCKET_SHIFT;
    address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);

MCACHE_BUCKET_SHIFT depends on a system (32/64) and is equal to 20 for
a 64-bit system (which assumed for the further description). Basically,
this means that we deal with 1 MB chunks and offsets within those 1 MB
chunks. All mappings are created with 1MB-granularity, i.e. 1MB/2MB/3MB
etc. Most DMA transfers typically are less than 1MB, however, if the
transfer crosses any 1MB border(s) - than a nearest larger mapping size
will be used, so ex. a 512-byte DMA transfer with the start address
700FFF80h will actually require a 2MB range.

Current implementation assumes that MapCacheEntries are unique for a given
address_index and size pair and that a single MapCacheEntry may be reused
by multiple requests -- in this case the 'lock' field will be larger than
1. On other hand, each requested guest physical address (with 'lock' flag)
is described by each own MapCacheRev. So there may be multiple MapCacheRev
entries corresponding to a single MapCacheEntry. The xen-mapcache code
uses MapCacheRev entries to retrieve the address_index & size pair which
in turn used to find a related MapCacheEntry. The 'lock' field within
a MapCacheEntry structure is actually a reference counter which shows
a number of corresponding MapCacheRev entries.

The bug lies in ability for the guest to indirectly manipulate with the
xen-mapcache MapCacheEntries list via a special sequence of DMA
operations, typically for storage devices. In order to trigger the bug,
guest needs to issue DMA operations in specific order and timing.
Although xen-mapcache is protected by the mutex lock -- this doesn't help
in this case, as the bug is not due to a race condition.

Suppose we have 3 DMA transfers, namely A, B and C, where
- transfer A crosses 1MB border and thus uses a 2MB mapping
- transfers B and C are normal transfers within 1MB range
- and all 3 transfers belong to the same address_index

In this case, if all these transfers are to be executed one-by-one
(without overlaps), no special treatment necessary -- each transfer's
mapping lock will be set and then cleared on unmap before starting
the next transfer.
The situation changes when DMA transfers overlap in time, ex. like this:

  |===== transfer A (2MB) =====|

              |===== transfer B (1MB) =====|

                          |===== transfer C (1MB) =====|
 time --->

In this situation the following sequence of actions happens:

1. transfer A creates a mapping to 2MB area (lock=1)
2. transfer B (1MB) tries to find available mapping but cannot find one
   because transfer A is still in progress, and it has 2MB size + non-zero
   lock. So transfer B creates another mapping -- same address_index,
   but 1MB size.
3. transfer A completes, making 1st mapping entry available by setting its
   lock to 0
4. transfer C starts and tries to find available mapping entry and sees
   that 1st entry has lock=0, so it uses this entry but remaps the mapping
   to a 1MB size
5. transfer B completes and by this time
  - there are two locked entries in the MapCacheEntry list with the SAME
    values for both address_index and size
  - the entry for transfer B actually resides farther in list while
    transfer C's entry is first
6. xen_ram_addr_from_mapcache() for transfer B gets correct address_index
   and size pair from corresponding MapCacheRev entry, but then it starts
   looking for MapCacheEntry with these values and finds the first entry
   -- which belongs to transfer C.

At this point there may be following possible (bad) consequences:

1. xen_ram_addr_from_mapcache() will use a wrong entry->vaddr_base value
   in this statement:

   raddr = (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +
       ((unsigned long) ptr - (unsigned long) entry->vaddr_base);

resulting in an incorrent raddr value returned from the function. The
(ptr - entry->vaddr_base) expression may produce both positive and negative
numbers and its actual value may differ greatly as there are many
map/unmap operations take place. If the value will be beyond guest RAM
limits then a "Bad RAM offset" error will be triggered and logged,
followed by exit() in QEMU.

2. If raddr value won't exceed guest RAM boundaries, the same sequence
of actions will be performed for xen_invalidate_map_cache_entry() on DMA
unmap, resulting in a wrong MapCacheEntry being unmapped while DMA
operation which uses it is still active. The above example must
be extended by one more DMA transfer in order to allow unmapping as the
first mapping in the list is sort of resident.

The patch modifies the behavior in which MapCacheEntry's are added to the
list, avoiding duplicates.

Signed-off-by: Alexey Gerasimenko <x1917x@gmail.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen: fix compilation on 32-bit hosts
Igor Druzhinin [Sat, 22 Jul 2017 00:32:56 +0000 (17:32 -0700)]
xen: fix compilation on 32-bit hosts

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoconfigure: Drop ancient Solaris 9 and earlier support
Peter Maydell [Thu, 13 Jul 2017 14:21:37 +0000 (15:21 +0100)]
configure: Drop ancient Solaris 9 and earlier support

Solaris 9 was released in 2002, its successor Solaris 10 was
released in 2005, and Solaris 9 was end-of-lifed in 2014.
Nobody has stepped forward to express interest in supporting
Solaris of any flavour, so removing support for the ancient
versions seems uncontroversial.

In particular, this allows us to remove a use of 'uname'
in configure that won't work if you're cross-compiling.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1499955697-28045-1-git-send-email-peter.maydell@linaro.org

6 years agoconfigure: Never use 'uname' to identify target OS
Peter Maydell [Thu, 13 Jul 2017 15:15:32 +0000 (16:15 +0100)]
configure: Never use 'uname' to identify target OS

For a very long time we have used 'uname -s' as our fallback if
we don't identify the target OS using a compiler #define. This
obviously doesn't work for cross-compilation, and we've had
a comment suggesting we fix this in configure for a long time.
Since we now have an exhaustive list of which OSes we can run
on (thanks to commit 898be3e0415 making an unrecognized OS
be a fatal error), we know which ones we're missing.

Add check_define tests for the remaining OSes we support.  The
defines checked are based on ones we already use in the codebase for
identifying the host OS (with the exception of GNU/kFreeBSD).
We can now set bogus_os immediately rather than doing it later.

We leave the comment about uname being bad untouched, since
there is still a use of it for the fallback for unrecognized
host CPU type.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1499958932-23839-1-git-send-email-peter.maydell@linaro.org

6 years agobsd-user/main.c: Fix unused variable warning
Peter Maydell [Tue, 18 Jul 2017 16:26:34 +0000 (17:26 +0100)]
bsd-user/main.c: Fix unused variable warning

On OpenBSD the compiler warns:
bsd-user/main.c:622:21: warning: variable 'sig' set but not used [-Wunused-but-set-variable]

This is because a lot of the signal delivery code is #if-0'd
out as unused. Reshuffle #ifdefs a bit to silence the warning.

(We make the minimum change here rather than removing all the
bsd-user patchset which should make this all work correctly and
there's no point giving them an awkward rebase task.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1500395194-21455-5-git-send-email-peter.maydell@linaro.org

6 years agobsd-user/bsdload.c: Remove write-only id_change variable
Peter Maydell [Tue, 18 Jul 2017 16:26:33 +0000 (17:26 +0100)]
bsd-user/bsdload.c: Remove write-only id_change variable

On OpenBSD the compiler complains:
bsd-user/bsdload.c:54:17: warning: variable 'id_change' set but not used [-Wunused-but-set-variable]

This is dead code that was originally copied from linux-user.
We fixed this in linux-user in commit 331c23b5ca44293d1 in 2011;
delete the useless code from bsd-user too.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-id: 1500395194-21455-4-git-send-email-peter.maydell@linaro.org

6 years agoblock/vpc: fix uninitialised variable compiler warning
Mark Cave-Ayland [Fri, 21 Jul 2017 08:21:05 +0000 (09:21 +0100)]
block/vpc: fix uninitialised variable compiler warning

Since commit cfc87e00 "block/vpc.c: Handle write failures in
get_image_offset()" older versions of gcc (in this case 4.7) incorrectly
warn that "ret" can be used uninitialised in vpc_co_pwritev().

Setting ret to 0 at the start of vpc_co_pwritev() prevents the warning
in gcc 4.7 and enables compilation with -Werror to succeed.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1500625265-23844-1-git-send-email-mark.cave-ayland@ilande.co.uk
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/yongbok/tags/mips-20170721' into staging
Peter Maydell [Fri, 21 Jul 2017 12:28:51 +0000 (13:28 +0100)]
Merge remote-tracking branch 'remotes/yongbok/tags/mips-20170721' into staging

MIPS patches 2017-07-21

Changes:
* Add Enhanced Virtual Addressing (EVA) support

# gpg: Signature made Fri 21 Jul 2017 03:25:15 BST
# gpg:                using RSA key 0x2238EB86D5F797C2
# gpg: Good signature from "Yongbok Kim <yongbok.kim@imgtec.com>"
# 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: 8600 4CF5 3415 A5D9 4CFA  2B5C 2238 EB86 D5F7 97C2

* remotes/yongbok/tags/mips-20170721:
  target/mips: Enable CP0_EBase.WG on MIPS64 CPUs
  target/mips: Add EVA support to P5600
  target/mips: Implement segmentation control
  target/mips: Add segmentation control registers
  target/mips: Add an MMU mode for ERL
  target/mips: Abstract mmu_idx from hflags
  target/mips: Check memory permissions with mem_idx
  target/mips: Decode microMIPS EVA load & store instructions
  target/mips: Decode MIPS32 EVA load & store instructions
  target/mips: Prepare loads/stores for EVA
  target/mips: Add CP0_Ebase.WG (write gate) support
  target/mips: Weaken TLB flush on UX,SX,KX,ASID changes
  target/mips: Fix TLBWI shadow flush for EHINV,XI,RI
  target/mips: Fix MIPS64 MFC0 UserLocal on BE host

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-ci-updates-for-softfreeze...
Peter Maydell [Fri, 21 Jul 2017 10:44:53 +0000 (11:44 +0100)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-ci-updates-for-softfreeze-180717-2' into staging

Final CI updates for soft-freeze

Tweaks from Paolo for J=x Travis compiles
Bunch of updated cross-compile targets from Philippe
Additional debug tools in travis image from Me

# gpg: Signature made Tue 18 Jul 2017 11:00:26 BST
# gpg:                using RSA key 0xFBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>"
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-ci-updates-for-softfreeze-180717-2: (32 commits)
  docker: install clang since Shippable setup_ve() verify it is available
  docker: warn users to use newer debian8/debian9 base image
  docker: add debian Ports base image
  shippable: add win32/64 targets
  docker: add MXE (M cross environment) base image for MinGW-w64
  shippable: add mips64el targets
  docker: add debian/mips64el image
  shippable: use debian/mips[eb] targets
  docker: add debian/mips[eb] images
  shippable: add powerpc target
  docker: add debian/powerpc based on Jessie
  docker: add 'apt-fake' script which generate fake debian packages
  docker: add qemu:debian-jessie based on outdated jessie release
  shippable: add x86_64 targets
  shippable: add ppc64el targets
  shippable: add armel targets
  docker: enable nettle to extend code coverage on arm64
  docker: enable gcrypt to extend code coverage on amd64
  docker: enable netmap to extend code coverage on amd64
  docker: enable virgl to extend code coverage on amd64
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agobsd-user/elfload.c: Fix set-but-not-used warnings
Peter Maydell [Tue, 18 Jul 2017 16:26:32 +0000 (17:26 +0100)]
bsd-user/elfload.c: Fix set-but-not-used warnings

Fix various warnings about set-but-not-used variables on OpenBSD:

bsd-user/elfload.c:1158:15: warning: variable 'mapped_addr' set but not used [-Wunused-but-set-variable]
bsd-user/elfload.c:1165:9: warning: variable 'status' set but not used [-Wunused-but-set-variable]
bsd-user/elfload.c:1168:15: warning: variable 'elf_stack' set but not used [-Wunused-but-set-variable]

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1500395194-21455-3-git-send-email-peter.maydell@linaro.org

6 years agobsd-user/mmap.c: Move __thread attribute to right place
Peter Maydell [Tue, 18 Jul 2017 16:26:31 +0000 (17:26 +0100)]
bsd-user/mmap.c: Move __thread attribute to right place

Avoid a compiler warning on OpenBSD:
bsd-user/mmap.c:28:1: warning: '__thread' is not at beginning of declaration [-Wold-style-declaration]
by moving the __thread attribute to its proper place.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1500395194-21455-2-git-send-email-peter.maydell@linaro.org

6 years agoUse qemu_tolower() and qemu_toupper(), not tolower() and toupper()
Peter Maydell [Thu, 20 Jul 2017 16:31:30 +0000 (17:31 +0100)]
Use qemu_tolower() and qemu_toupper(), not tolower() and toupper()

On NetBSD, where tolower() and toupper() are implemented using an
array lookup, the compiler warns if you pass a plain 'char'
to these functions:

gdbstub.c:914:13: warning: array subscript has type 'char'

This reflects the fact that toupper() and tolower() give
undefined behaviour if they are passed a value that isn't
a valid 'unsigned char' or EOF.

We have qemu_tolower() and qemu_toupper() to avoid this problem;
use them.

(The use in scsi-generic.c does not trigger the warning because
it passes a uint8_t; we switch it anyway, for consistency.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> for the s390 part.
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-id: 1500568290-7966-1-git-send-email-peter.maydell@linaro.org

6 years agoutil/oslib-posix.c: Avoid warning on NetBSD
Peter Maydell [Thu, 20 Jul 2017 16:32:21 +0000 (17:32 +0100)]
util/oslib-posix.c: Avoid warning on NetBSD

On NetBSD the compiler warns:
util/oslib-posix.c: In function 'sigaction_invoke':
util/oslib-posix.c:589:5: warning: missing braces around initializer [-Wmissing-braces]
     siginfo_t si = { 0 };
     ^
util/oslib-posix.c:589:5: warning: (near initialization for 'si.si_pad') [-Wmissing-braces]

because on this platform siginfo_t is defined as
  typedef union siginfo {
          char    si_pad[128];    /* Total size; for future expansion */
          struct _ksiginfo _info;
  } siginfo_t;

Avoid this warning by initializing the struct with {} instead;
this is a GCC extension but we use it all over the codebase already.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1500568341-8389-1-git-send-email-peter.maydell@linaro.org

6 years agotarget/mips: Enable CP0_EBase.WG on MIPS64 CPUs
James Hogan [Tue, 18 Jul 2017 11:55:59 +0000 (12:55 +0100)]
target/mips: Enable CP0_EBase.WG on MIPS64 CPUs

Enable the CP0_EBase.WG (write gate) on the I6400 and MIPS64R2-generic
CPUs. This allows 64-bit guests to run KVM itself, which uses
CP0_EBase.WG to point CP0_EBase at XKPhys.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Add EVA support to P5600
James Hogan [Tue, 18 Jul 2017 11:55:58 +0000 (12:55 +0100)]
target/mips: Add EVA support to P5600

Add the Enhanced Virtual Addressing (EVA) feature to the P5600 core
configuration, along with the related Segmentation Control (SC) feature
and writable CP0_EBase.WG bit.

This allows it to run Malta EVA kernels.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Implement segmentation control
James Hogan [Tue, 18 Jul 2017 11:55:57 +0000 (12:55 +0100)]
target/mips: Implement segmentation control

Implement the optional segmentation control feature in the virtual to
physical address translation code.

The fixed legacy segment and xkphys handling is replaced with a dynamic
layout based on the segmentation control registers (which should be set
up even when the feature is not exposed to the guest).

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
[yongbok.kim@imgtec.com:
  cosmetic changes]
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Add segmentation control registers
James Hogan [Tue, 18 Jul 2017 11:55:56 +0000 (12:55 +0100)]
target/mips: Add segmentation control registers

The optional segmentation control registers CP0_SegCtl0, CP0_SegCtl1 &
CP0_SegCtl2 control the behaviour and required privilege of the legacy
virtual memory segments.

Add them to the CP0 interface so they can be read and written when
CP0_Config3.SC=1, and initialise them to describe the standard legacy
layout so they can be used in future patches regardless of whether they
are exposed to the guest.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Add an MMU mode for ERL
James Hogan [Tue, 18 Jul 2017 11:55:55 +0000 (12:55 +0100)]
target/mips: Add an MMU mode for ERL

The segmentation control feature allows a legacy memory segment to
become unmapped uncached at error level (according to CP0_Status.ERL),
and in fact the user segment is already treated in this way by QEMU.

Add a new MMU mode for this state so that QEMU's mappings don't persist
between ERL=0 and ERL=1.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
[yongbok.kim@imgtec.com:
  cosmetic changes]
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Abstract mmu_idx from hflags
James Hogan [Tue, 18 Jul 2017 11:55:54 +0000 (12:55 +0100)]
target/mips: Abstract mmu_idx from hflags

The MIPS mmu_idx is sometimes calculated from hflags without an env
pointer available as cpu_mmu_index() requires.

Create a common hflags_mmu_index() for the purpose of this calculation
which can operate on any hflags, not just with an env pointer, and
update cpu_mmu_index() itself and gen_intermediate_code() to use it.

Also update debug_post_eret() and helper_mtc0_status() to log the MMU
mode with the status change (SM, UM, or nothing for kernel mode) based
on cpu_mmu_index() rather than directly testing hflags.

This will also allow the logic to be more easily updated when a new MMU
mode is added.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Check memory permissions with mem_idx
James Hogan [Tue, 18 Jul 2017 11:55:53 +0000 (12:55 +0100)]
target/mips: Check memory permissions with mem_idx

When performing virtual to physical address translation, check the
required privilege level based on the mem_idx rather than the mode in
the hflags. This will allow EVA loads & stores to operate safely only on
user memory from kernel mode.

For the cases where the mmu_idx doesn't need to be overridden
(mips_cpu_get_phys_page_debug() and cpu_mips_translate_address()), we
calculate the required mmu_idx using cpu_mmu_index(). Note that this
only tests the MIPS_HFLAG_KSU bits rather than MIPS_HFLAG_MODE, so we
don't test the debug mode hflag MIPS_HFLAG_DM any longer. This should be
fine as get_physical_address() only compares against MIPS_HFLAG_UM and
MIPS_HFLAG_SM, neither of which should get set by compute_hflags() when
MIPS_HFLAG_DM is set.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Decode microMIPS EVA load & store instructions
James Hogan [Tue, 18 Jul 2017 11:55:52 +0000 (12:55 +0100)]
target/mips: Decode microMIPS EVA load & store instructions

Implement decoding of microMIPS EVA load and store instruction groups in
the POOL31C pool. These use the same gen_ld(), gen_st(), gen_st_cond()
helpers as the MIPS32 decoding, passing the equivalent MIPS32 opcodes as
opc.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Decode MIPS32 EVA load & store instructions
James Hogan [Tue, 18 Jul 2017 11:55:51 +0000 (12:55 +0100)]
target/mips: Decode MIPS32 EVA load & store instructions

Implement decoding of MIPS32 EVA loads and stores. These access the user
address space from kernel mode when implemented, so for each instruction
we need to check that EVA is available from Config5.EVA & check for
sufficient COP0 privilege (with the new check_eva()), and then override
the mem_idx used for the operation.

Unfortunately some Loongson 2E instructions use overlapping encodings,
so we must be careful not to prevent those from being decoded when EVA
is absent.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Prepare loads/stores for EVA
James Hogan [Tue, 18 Jul 2017 11:55:50 +0000 (12:55 +0100)]
target/mips: Prepare loads/stores for EVA

EVA load and store instructions access the user mode address map, so
they need to use mem_idx of MIPS_HFLAG_UM. Update the various utility
functions to allow mem_idx to be more easily overridden from the
decoding logic.

Specifically we add a mem_idx argument to the op_ld/st_* helpers used
for atomics, and a mem_idx local variable to gen_ld(), gen_st(), and
gen_st_cond().

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Add CP0_Ebase.WG (write gate) support
James Hogan [Tue, 18 Jul 2017 11:55:49 +0000 (12:55 +0100)]
target/mips: Add CP0_Ebase.WG (write gate) support

Add support for the CP0_EBase.WG bit, which allows upper bits to be
written (bits 31:30 on MIPS32, or bits 63:30 on MIPS64), along with the
CP0_Config5.CV bit to control whether the exception vector for Cache
Error exceptions is forced into KSeg1.

This is necessary on MIPS32 to support Segmentation Control and Enhanced
Virtual Addressing (EVA) extensions (where KSeg1 addresses may not
represent an unmapped uncached segment).

It is also useful on MIPS64 to allow the exception base to reside in
XKPhys, and possibly out of range of KSEG0 and KSEG1.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
[yongbok.kim@imgtec.com:
  minor changes]
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Weaken TLB flush on UX,SX,KX,ASID changes
James Hogan [Tue, 18 Jul 2017 11:55:48 +0000 (12:55 +0100)]
target/mips: Weaken TLB flush on UX,SX,KX,ASID changes

There is no need to invalidate any shadow TLB entries when the ASID
changes or when access to one of the 64-bit segments has been disabled,
since doing so doesn't reveal to software whether any TLB entries have
been evicted into the shadow half of the TLB.

Therefore weaken the tlb flushes in these cases to only flush the QEMU
TLB.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Fix TLBWI shadow flush for EHINV,XI,RI
James Hogan [Tue, 18 Jul 2017 11:55:47 +0000 (12:55 +0100)]
target/mips: Fix TLBWI shadow flush for EHINV,XI,RI

Writing specific TLB entries with TLBWI flushes shadow TLB entries
unless an existing entry is having its access permissions upgraded. This
is necessary as software would from then on expect the previous mapping
in that entry to no longer be in effect (even if QEMU has quietly
evicted it to the shadow TLB on a TLBWR).

However it won't do this if only EHINV, XI, or RI bits have been set,
even if that results in a reduction of permissions, so add the necessary
checks to invoke the flush when these bits are set.

Fixes: 2fb58b73746e ("target-mips: add RI and XI fields to TLB entry")
Fixes: 9456c2fbcd82 ("target-mips: add TLBINV support")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Yongbok Kim <yongbok.kim@imgtec.com>
[yongbok.kim@imgtec.com:
  cosmetic changes]
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agotarget/mips: Fix MIPS64 MFC0 UserLocal on BE host
James Hogan [Tue, 18 Jul 2017 11:55:46 +0000 (12:55 +0100)]
target/mips: Fix MIPS64 MFC0 UserLocal on BE host

Using MFC0 to read CP0_UserLocal uses tcg_gen_ld32s_tl, however
CP0_UserLocal is a target_ulong. On a big endian host with a MIPS64
target this reads and sign extends the more significant half of the
64-bit register.

Fix this by using ld_tl to load the whole target_ulong and ext32s_tl to
sign extend it, as done for various other target_ulong COP0 registers.

Fixes: d279279e2b5c ("target-mips: implement UserLocal Register")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
6 years agoMerge remote-tracking branch 'remotes/kraxel/tags/usb-20170720-pull-request' into...
Peter Maydell [Thu, 20 Jul 2017 16:52:48 +0000 (17:52 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20170720-pull-request' into staging

usb: Fix build with newer gcc

# gpg: Signature made Thu 20 Jul 2017 09:44:55 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/usb-20170720-pull-request:
  usb: Fix build with newer gcc

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/kraxel/tags/ui-20170720-pull-request' into...
Peter Maydell [Thu, 20 Jul 2017 15:40:01 +0000 (16:40 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20170720-pull-request' into staging

ui fixes (vnc docs, keymaps) for 2.10

# gpg: Signature made Thu 20 Jul 2017 08:54:25 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20170720-pull-request:
  keymaps: fr-ca: more fixups
  vnc: Clarify documentation of QMP command change

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agotests: Handle $RANDOM not being supported by the shell
Peter Maydell [Fri, 14 Jul 2017 10:45:17 +0000 (11:45 +0100)]
tests: Handle $RANDOM not being supported by the shell

In various places in our test makefiles and scripts we use the
shell $RANDOM to create a random number. This is a bash
specific extension, and doesn't work on other shells.
With dash the shell doesn't complain, it just effectively
always evaluates $RANDOM to 0:
  echo $((RANDOM + 32768))     => 32768

However, on NetBSD the shell will complain:
  "-sh: arith: syntax error: "RANDOM + 32768"

which means that "make check" fails.

Switch to using "${RANDOM:-0}" instead of $RANDOM,
which will portably either give us a random number or zero.
This means that on non-bash shells we don't get such
good test coverage via the MALLOC_PERTURB_ setting, but
we were already in that situation for non-bash shells.

Our only other uses of $RANDOM (in tests/qemu-iotests/check
and tests/qemu-iotests/162) are in shell scripts which use
a #!/bin/bash line so they are always run under bash.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Kamil Rytarowski <n54@gmx.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1500029117-6387-1-git-send-email-peter.maydell@linaro.org

6 years agoconfigure: Don't build ivshmem tools unless CONFIG_IVSHMEM is set
Kamil Rytarowski [Fri, 14 Jul 2017 08:33:45 +0000 (09:33 +0100)]
configure: Don't build ivshmem tools unless CONFIG_IVSHMEM is set

Don't try to build the ivshmem-server and ivshmem-client tools unless
CONFIG_IVSHMEM is set.

This fixes in passing a build bug on NetBSD, which fails to build the
ivshmem tools because they use shm_open() and on NetBSD that requires
linking against -lrt.

Signed-off-by: Kamil Rytarowski <n54@gmx.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1500021225-4118-4-git-send-email-peter.maydell@linaro.org
[PMM: moved some code into earlier patches; minor bugfixes;
 added commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoconfigure: Use an explicit CONFIG_IVSHMEM rather than CONFIG_EVENTFD
Kamil Rytarowski [Fri, 14 Jul 2017 08:33:44 +0000 (09:33 +0100)]
configure: Use an explicit CONFIG_IVSHMEM rather than CONFIG_EVENTFD

Rather than relying on everywhere that cares about whether the host
supports ivshmem using CONFIG_EVENTFD, make configure set an explicit
CONFIG_IVSHMEM.

Signed-off-by: Kamil Rytarowski <n54@gmx.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1500021225-4118-3-git-send-email-peter.maydell@linaro.org
[PMM: split out from another patch, add commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoconfigure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE
Peter Maydell [Fri, 14 Jul 2017 08:33:43 +0000 (09:33 +0100)]
configure: Rename CONFIG_IVSHMEM to CONFIG_IVSHMEM_DEVICE

The current CONFIG_IVSHMEM is confusing, because it looks like it's a
flag for "do we have ivshmem support?", but actually it's a flag for
"is the ivshmem PCI device being compiled?" (and implicitly "do we
have ivshmem support?" is tested with CONFIG_EVENTFD).

Rename it to CONFIG_IVSHMEM_DEVICE to clear this confusion up;
shortly we will add a new CONFIG_IVSHMEM which really does indicate
whether the host can support ivshmem.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1500021225-4118-2-git-send-email-peter.maydell@linaro.org

6 years agoMerge remote-tracking branch 'remotes/kraxel/tags/misc-20170720-pull-request' into...
Peter Maydell [Thu, 20 Jul 2017 11:04:05 +0000 (12:04 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/misc-20170720-pull-request' into staging

git orderfile and editorconfig for 2.10

# gpg: Signature made Thu 20 Jul 2017 09:00:01 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/misc-20170720-pull-request:
  add editorconfig
  add scripts/git.orderfile

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20170719' into staging
Peter Maydell [Thu, 20 Jul 2017 10:00:10 +0000 (11:00 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20170719' into staging

Queued tcg and tcg code gen related cleanups

# gpg: Signature made Thu 20 Jul 2017 00:32:00 BST
# gpg:                using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC  16A4 AD12 70CC 4DD0 279B

* remotes/rth/tags/pull-tcg-20170719:
  tcg: Pass generic CPUState to gen_intermediate_code()
  tcg/tci: enable bswap16_i64
  target/alpha: optimize gen_cvtlq() using deposit op
  target/sparc: optimize gen_op_mulscc() using deposit op
  target/sparc: optimize various functions using extract op
  target/ppc: optimize various functions using extract op
  target/m68k: optimize bcd_flags() using extract op
  target/arm: optimize aarch32 rev16
  target/arm: Optimize aarch64 rev16
  coccinelle: add a script to optimize tcg op using tcg_gen_extract()
  coccinelle: ignore ASTs pre-parsed cached C files
  tcg: Expand glue macros before stringifying helper names
  util/cacheinfo: Add missing include for ppc linux
  tcg/mips: reserve a register for the guest_base.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoReplace 'struct ucontext' with 'ucontext_t' type
Khem Raj [Wed, 28 Jun 2017 20:44:52 +0000 (13:44 -0700)]
Replace 'struct ucontext' with 'ucontext_t' type

glibc used to have:

   typedef struct ucontext { ... } ucontext_t;

glibc now has:

   typedef struct ucontext_t { ... } ucontext_t;

(See https://sourceware.org/bugzilla/show_bug.cgi?id=21457
 for detail and rationale for the glibc change)

However, QEMU used "struct ucontext" in declarations. This is a
private name and compatibility cannot be guaranteed. Switch to
only using the standardized type name.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Message-id: 20170628204452.41230-1-raj.khem@gmail.com
Cc: Kamil Rytarowski <kamil@netbsd.org>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[PMM: Rewrote commit message, based mostly on the one from
 Nathaniel McCallum]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agousb: Fix build with newer gcc
Eric Blake [Mon, 17 Jul 2017 15:13:34 +0000 (10:13 -0500)]
usb: Fix build with newer gcc

gcc 7 is pickier about our sources:

hw/usb/bus.c: In function ‘usb_port_location’:
hw/usb/bus.c:410:66: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 15 [-Werror=format-truncation=]
         snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
                                                                  ^~
hw/usb/bus.c:410:9: note: ‘snprintf’ output between 3 and 28 bytes into a destination of size 16
         snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  upstream->path, portnr);
                  ~~~~~~~~~~~~~~~~~~~~~~~

But we know that there are at most 5 levels of USB hubs, with at
most two digits per level; that plus the separating dots means we
use at most 15 bytes (including trailing NUL) of our 16-byte field.
Adding an assertion to show gcc that we checked for truncation is
enough to shut up the false-positive warning.

Inspired by an idea by Dr. David Alan Gilbert <dgilbert@redhat.com>.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20170717151334.17954-1-eblake@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
6 years agoadd editorconfig
Gerd Hoffmann [Mon, 17 Jul 2017 10:15:47 +0000 (12:15 +0200)]
add editorconfig

Add a .editorconfig file for qemu.  Specifies the indent and tab style
for various files (C code and Makefiles for starters).  Most popular
editors support this either natively or via plugin.

Check http://editorconfig.org/ for details.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20170717101547.22295-1-kraxel@redhat.com

6 years agoadd scripts/git.orderfile
Gerd Hoffmann [Mon, 17 Jul 2017 10:16:32 +0000 (12:16 +0200)]
add scripts/git.orderfile

Based on a old patch by Laszlo.
Time to get this in ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Message-id: 20170717101632.23247-1-kraxel@redhat.com

6 years agokeymaps: fr-ca: more fixups
Gerd Hoffmann [Mon, 17 Jul 2017 13:34:44 +0000 (15:34 +0200)]
keymaps: fr-ca: more fixups

Fixes: https://bugs.launchpad.net/qemu/+bug/533613
Cc: Thomas Huth <thuth@redhat.com>
Suggested-by: Jérôme Poulin <jeromepoulin@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20170717133444.16743-1-kraxel@redhat.com

6 years agovnc: Clarify documentation of QMP command change
Markus Armbruster [Wed, 19 Jul 2017 07:09:42 +0000 (09:09 +0200)]
vnc: Clarify documentation of QMP command change

QMP command

    { "execute": "change",
      "arguments": { "device": "vnc", "target": "password", "arg": PWD } }

behaves just like

    { "execute": "change-vnc-password",
      "arguments": { "password", "arg": PWD } }

Their documentation differs, however.  According to
change-vnc-password's documentation, "an empty password [...] will set
the password to the empty string", while change's documentation claims
"no future logins will be allowed".  The former is actually correct.
Replace the incorrect claim by a reference to change-vnc-password.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 1500448182-21376-1-git-send-email-armbru@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
6 years agotcg: Pass generic CPUState to gen_intermediate_code()
Lluís Vilanova [Fri, 14 Jul 2017 08:17:35 +0000 (11:17 +0300)]
tcg: Pass generic CPUState to gen_intermediate_code()

Needed to implement a target-agnostic gen_intermediate_code()
in the future.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Alex Benneé <alex.benee@linaro.org>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Message-Id: <150002025498.22386.18051908483085660588.stgit@frigg.lan>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/tci: enable bswap16_i64
Philippe Mathieu-Daudé [Tue, 18 Jul 2017 04:55:40 +0000 (01:55 -0300)]
tcg/tci: enable bswap16_i64

Altough correctly implemented, bswap16_i64() never got tested/executed so the
safety TODO() statement was never removed.

Since it got now tested the TODO() can be removed.

while running Alex Bennée's image aarch64-linux-3.15rc2-buildroot.img:

Trace 0x7fa1904b0890 [0: ffffffc00036cd04]
----------------
IN:
0xffffffc00036cd24:  5ac00694      rev16 w20, w20

OP:
 ---- ffffffc00036cd24 0000000000000000 0000000000000000
 ext32u_i64 tmp3,x20
 ext16u_i64 tmp2,tmp3
 bswap16_i64 x20,tmp2
 movi_i64 tmp4,$0x10
 shr_i64 tmp2,tmp3,tmp4
 ext16u_i64 tmp2,tmp2
 bswap16_i64 tmp2,tmp2
 deposit_i64 x20,x20,tmp2,$0x10,$0x10

Linking TBs 0x7fa1904b0890 [ffffffc00036cd04] index 0 -> 0x7fa1904b0aa0 [ffffffc00036cd24]
Trace 0x7fa1904b0aa0 [0: ffffffc00036cd24]
TODO qemu/tci.c:1049: tcg_qemu_tb_exec()
qemu/tci.c:1049: tcg fatal error
Aborted

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jaroslaw Pelczar <j.pelczar@samsung.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Message-Id: <20170718045540.16322-11-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/alpha: optimize gen_cvtlq() using deposit op
Philippe Mathieu-Daudé [Tue, 18 Jul 2017 04:55:39 +0000 (01:55 -0300)]
target/alpha: optimize gen_cvtlq() using deposit op

Suggested-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20170718045540.16322-10-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/sparc: optimize gen_op_mulscc() using deposit op
Philippe Mathieu-Daudé [Tue, 18 Jul 2017 04:55:38 +0000 (01:55 -0300)]
target/sparc: optimize gen_op_mulscc() using deposit op

Suggested-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20170718045540.16322-9-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/sparc: optimize various functions using extract op
Philippe Mathieu-Daudé [Tue, 18 Jul 2017 04:55:36 +0000 (01:55 -0300)]
target/sparc: optimize various functions using extract op

Done with the Coccinelle semantic patch
scripts/coccinelle/tcg_gen_extract.cocci.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/ppc: optimize various functions using extract op
Philippe Mathieu-Daudé [Tue, 18 Jul 2017 04:55:35 +0000 (01:55 -0300)]
target/ppc: optimize various functions using extract op

Done with the Coccinelle semantic patch
scripts/coccinelle/tcg_gen_extract.cocci.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20170718045540.16322-6-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/m68k: optimize bcd_flags() using extract op
Philippe Mathieu-Daudé [Tue, 18 Jul 2017 04:55:34 +0000 (01:55 -0300)]
target/m68k: optimize bcd_flags() using extract op

Done with the Coccinelle semantic patch
scripts/coccinelle/tcg_gen_extract.cocci.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-Id: <20170718045540.16322-5-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/arm: optimize aarch32 rev16
Aurelien Jarno [Tue, 16 May 2017 23:01:56 +0000 (01:01 +0200)]
target/arm: optimize aarch32 rev16

Use the same mask to avoid having to load two different constants, as
suggested by Richard Henderson.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-Id: <20170516230159.4195-2-aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>