sdk/emulator/qemu.git
11 years agopseries: savevm support for pseries machine
David Gibson [Thu, 18 Jul 2013 19:33:01 +0000 (14:33 -0500)]
pseries: savevm support for pseries machine

This adds the necessary pieces to implement savevm / migration for the
pseries machine.  The most complex part here is migrating the hash
table - for the paravirtualized pseries machine the guest's hash page
table is not stored within guest memory, but externally and the guest
accesses it via hypercalls.

This patch uses a hypervisor reserved bit of the HPTE as a dirty bit
(tracking changes to the HPTE itself, not the page it references).
This is used to implement a live migration style incremental save and
restore of the hash table contents.

Normally a hash table is 16MB but it can get bigger depending on how
much RAM the guest has. Due to its nature, updates to it are random so
the live migration style is used for it.

In addition it adds VMStateDescription information to save and restore
the (few) remaining pieces of state information needed by the pseries
machine.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1374175984-8930-9-git-send-email-aliguori@us.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopseries: savevm support for PAPR virtual SCSI
David Gibson [Thu, 18 Jul 2013 19:33:00 +0000 (14:33 -0500)]
pseries: savevm support for PAPR virtual SCSI

This patch adds the necessary support for saving the state of the PAPR VIO
virtual SCSI device. This also saves and restores active SCSI requests.

[aik: implemented vscsi_req save/restore]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-id: 1374175984-8930-8-git-send-email-aliguori@us.ibm.com
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopseries: rework PAPR virtual SCSI
Alexey Kardashevskiy [Thu, 18 Jul 2013 19:32:59 +0000 (14:32 -0500)]
pseries: rework PAPR virtual SCSI

The patch reimplements handling of indirect requests in order to
simplify upcoming live migration support.
- all pointers (except SCSIRequest*) were replaces with integer
indexes and offsets;
- DMA'ed srp_direct_buf kept untouched (ie. BE format);
- vscsi_fetch_desc() is added, now it is the only place where
descriptors are fetched and byteswapped;
- vscsi_req struct fields converted to migration-friendly types;
- many dprintf()'s fixed.

This also removed an unused field 'lun' from the spapr_vscsi device
which is assigned, but never used.  So, remove it.

[David Gibson: removed unused 'lun']
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-id: 1374175984-8930-7-git-send-email-aliguori@us.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agospapr-tce: make sPAPRTCETable a proper device
Anthony Liguori [Thu, 18 Jul 2013 19:32:58 +0000 (14:32 -0500)]
spapr-tce: make sPAPRTCETable a proper device

Model TCE tables as a device that's hooked up as a child object to
the owner.  Besides the code cleanup, we get a few nice benefits:

1) free actually works now (it was dead code before)

2) the TCE information is visible in the device tree

3) we can expose table information as properties such that if we
   change the window_size, we can use globals to keep migration
   working.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-id: 1374175984-8930-6-git-send-email-aliguori@us.ibm.com
[dwg: pseries: savevm support for PAPR TCE tables]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[alexey: ppc kvm: fix to compile]
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopseries: savevm support for PAPR VIO logical tty
David Gibson [Thu, 18 Jul 2013 19:32:57 +0000 (14:32 -0500)]
pseries: savevm support for PAPR VIO logical tty

This patch adds the necessary VMStateDescription information to support
savevm/loadvm for the spapr_tty (PAPR logical serial) device.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1374175984-8930-5-git-send-email-aliguori@us.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopseries: savevm support for PAPR VIO logical lan
David Gibson [Thu, 18 Jul 2013 19:32:56 +0000 (14:32 -0500)]
pseries: savevm support for PAPR VIO logical lan

This patch adds the necessary VMStateDescription information to support
savevm/loadvm for the spapr_llan (PAPR logical lan) device.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1374175984-8930-4-git-send-email-aliguori@us.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopseries: savevm support for VIO devices
David Gibson [Thu, 18 Jul 2013 19:32:55 +0000 (14:32 -0500)]
pseries: savevm support for VIO devices

This patch adds helpers to allow PAPR VIO devices to save state common
to all VIO devices during savevm.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1374175984-8930-3-git-send-email-aliguori@us.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agotarget-ppc: Convert ppc cpu savevm to VMStateDescription
Alexey Kardashevskiy [Thu, 18 Jul 2013 19:32:54 +0000 (14:32 -0500)]
target-ppc: Convert ppc cpu savevm to VMStateDescription

The savevm code for the powerpc cpu emulation is currently based around
the old register_savevm() rather than register_vmstate() method.  It's also
rather broken, missing some important state on some CPU models.

This patch completely rewrites the savevm for target-ppc, using the new
VMStateDescription approach.  Exactly what needs to be saved in what
configurations has been more carefully examined, too.  This introduces a
new version (5) of the cpu save format.  The old load function is retained
to support version 4 images.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-id: 1374175984-8930-2-git-send-email-aliguori@us.ibm.com
[aik: ppc cpu savevm convertion fixed to use PowerPCCPU instead of CPUPPCState]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'sstabellini/xen-130729' into staging
Anthony Liguori [Mon, 29 Jul 2013 12:30:31 +0000 (07:30 -0500)]
Merge remote-tracking branch 'sstabellini/xen-130729' into staging

# By Paul Durrant (1) and Stefano Stabellini (1)
# Via Stefano Stabellini
* sstabellini/xen-130729:
  Xen PV Device
  xen_disk: support "direct-io-safe" backend option

Message-id: 1375096790-12815-1-git-send-email-stefano.stabellini@eu.citrix.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'agraf/s390-for-upstream' into staging
Anthony Liguori [Mon, 29 Jul 2013 12:30:21 +0000 (07:30 -0500)]
Merge remote-tracking branch 'agraf/s390-for-upstream' into staging

# By Alexander Graf (1) and others
# Via Alexander Graf
* agraf/s390-for-upstream:
  s390: update s390-ccw.img
  s390/ipl: Fix boot order
  s390/IPL: Allow boot from other ssid than 0

Message-id: 1375092324-23943-1-git-send-email-agraf@suse.de
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'sweil/w32' into staging
Anthony Liguori [Mon, 29 Jul 2013 12:30:06 +0000 (07:30 -0500)]
Merge remote-tracking branch 'sweil/w32' into staging

# By Stefan Weil (10) and others
# Via Aurelien Jarno (1) and Stefan Weil (1)
* sweil/w32: (27 commits)
  w32, w64: Add build rule for installer
  target-mips: fix mipsdsp_mul_q31_q31
  mips_malta: fix copy of the 0x1fc00000 region
  linux-user: correct argument number for sys_mremap and sys_splice
  target-mips: Remove assignment to a variable which is never used
  target-mips: fix mipsdsp_trunc16_sat16_round
  hw/mips: align initrd to 64KB to avoid kernel error
  pflash_cfi01: duplicate status byte from bits 23:16 for 32bit reads
  mips_malta: generate SMBUS EEPROM data
  mips_malta: cap BIOS endian swap length at 0x3e0000 bytes
  mips_malta: generate SPD EEPROM data at runtime
  mips_malta: correct reading MIPS revision at 0x1fc00010
  mips_malta: fix BIOS endianness swapping
  mips_malta: QOM cast cleanup
  target-mips: fix branch in likely delay slot tcg assert
  target-mips: fix multiplication in mipsdsp_rndq15_mul_q15_q15
  target-mips: Remove assignment to a variable which is never used
  misc: Use g_assert_not_reached for code which is expected to be unreachable
  qemu-options: mention C-a h in the -nographic doc
  misc: Fix new typos in comments and strings
  ...

Message-id: 1374989579-24933-1-git-send-email-sw@weilnetz.de
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoXen PV Device
Paul Durrant [Mon, 29 Jul 2013 10:58:01 +0000 (10:58 +0000)]
Xen PV Device

Introduces a new Xen PV PCI device which will act as a binding point for
PV drivers for Xen.
The device has parameterized vendor-id, device-id and revision to allow to
be configured as a binding point for any vendor's PV drivers.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
11 years agoxen_disk: support "direct-io-safe" backend option
Stefano Stabellini [Mon, 29 Jul 2013 10:56:38 +0000 (10:56 +0000)]
xen_disk: support "direct-io-safe" backend option

Support backend option "direct-io-safe".  This is documented as
follows in the Xen backend specification:

 * direct-io-safe
 *      Values:         0/1 (boolean)
 *      Default Value:  0
 *
 *      The underlying storage is not affected by the direct IO memory
 *      lifetime bug.  See:
 *        http://lists.xen.org/archives/html/xen-devel/2012-12/msg01154.html
 *
 *      Therefore this option gives the backend permission to use
 *      O_DIRECT, notwithstanding that bug.
 *
 *      That is, if this option is enabled, use of O_DIRECT is safe,
 *      in circumstances where we would normally have avoided it as a
 *      workaround for that bug.  This option is not relevant for all
 *      backends, and even not necessarily supported for those for
 *      which it is relevant.  A backend which knows that it is not
 *      affected by the bug can ignore this option.
 *
 *      This option doesn't require a backend to use O_DIRECT, so it
 *      should not be used to try to control the caching behaviour.

Also, BDRV_O_NATIVE_AIO is ignored if BDRV_O_NOCACHE, so clarify the
default flags passed to the qemu block layer.

The original proposal for a "cache" backend option has been dropped
because it was believed too wide, especially considering that at the
moment the backend doesn't have a way to tell the toolstack that it is
capable of supporting it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
11 years agos390: update s390-ccw.img
Alexander Graf [Mon, 24 Jun 2013 12:56:51 +0000 (14:56 +0200)]
s390: update s390-ccw.img

This enables the following patches:

  s390/IPL: Allow boot from other ssid than 0
  s390/ipl: Fix spurious errors in virtio

Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agos390/ipl: Fix boot order
Christian Borntraeger [Tue, 18 Jun 2013 12:31:52 +0000 (14:31 +0200)]
s390/ipl: Fix boot order

The latest ipl code adaptions collided with some of the virtio
refactoring rework. This resulted in always booting the first
disk. Let's fix booting from a given ID.
The new code also checks for command lines without bootindex to
avoid random behaviour when accessing dev_st (==0).

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agos390/IPL: Allow boot from other ssid than 0
Dominik Dingel [Mon, 17 Jun 2013 12:29:42 +0000 (14:29 +0200)]
s390/IPL: Allow boot from other ssid than 0

We now take the subchannel set id also into account to find the boot device.
If we want to use a subchannel set other than the default set 0, we first
need to enable the mss facility.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agow32, w64: Add build rule for installer
Stefan Weil [Mon, 15 Jul 2013 21:49:57 +0000 (23:49 +0200)]
w32, w64: Add build rule for installer

The new rules in Makefile allow building installers for QEMU on Windows
using NSIS, a package which is also available for Linux distributions
(so cross builds are possible).

The rules for NSIS are in qemu.nsi which also uses two new images.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
11 years agoMerge branch 'trivial-patches' of git://git.corpit.ru/qemu
Aurelien Jarno [Mon, 29 Jul 2013 07:03:23 +0000 (09:03 +0200)]
Merge branch 'trivial-patches' of git://git.corpit.ru/qemu

* 'trivial-patches' of git://git.corpit.ru/qemu:
  target-mips: Remove assignment to a variable which is never used
  misc: Use g_assert_not_reached for code which is expected to be unreachable
  qemu-options: mention C-a h in the -nographic doc
  misc: Fix new typos in comments and strings
  linux-user: correct argument number for sys_mremap and sys_splice
  PPC: dbdma: macio: Fix format specifiers (build regression)
  watchdog: Remove break after exit
  exec: Remove env from list of poisoned names
  hw/9pfs: Fix potential memory leak and avoid reuse of freed memory
  timer: make timers_state static
  aes: Remove unused code (NDEBUG, u16)

11 years agotarget-mips: fix mipsdsp_mul_q31_q31
Petar Jovanovic [Mon, 29 Jul 2013 02:06:12 +0000 (04:06 +0200)]
target-mips: fix mipsdsp_mul_q31_q31

Multiplication of two fractional word elements is not correct when sign
extension/promotion is needed. This change fixes it by adding correct
casts from unsigned to signed values.
In addition, the tests (dpaq_sa_l_w.c and dpsq_sa_l_w.c) have been extended
to trigger the current issue.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: fix copy of the 0x1fc00000 region
Aurelien Jarno [Mon, 29 Jul 2013 05:00:29 +0000 (07:00 +0200)]
mips_malta: fix copy of the 0x1fc00000 region

Copy the whole 0x1fe000000 region into 0x1fc00000, independently of the
loaded BIOS size. This fix the MIPS make check tests.

Reported-by: Andreas Färber <afaerber@suse.de>
Tested-by: Andreas Färber <afaerber@suse.de>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agolinux-user: correct argument number for sys_mremap and sys_splice
Petar Jovanovic [Tue, 23 Jul 2013 17:00:10 +0000 (19:00 +0200)]
linux-user: correct argument number for sys_mremap and sys_splice

sys_mremap missed 5th argument (new_address), which caused examples that
remap to a specific address to fail.
sys_splice missed 5th and 6th argument which caused different examples to
fail.
This change has an effect on MIPS target only.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Remove assignment to a variable which is never used
Stefan Weil [Thu, 25 Jul 2013 20:10:31 +0000 (22:10 +0200)]
target-mips: Remove assignment to a variable which is never used

This assignment causes a compiler warning for compilations with the compiler
option -Wunused-but-set-variable (which is included with -Wextra).

Removing it allows using -Wextra for QEMU code without suppressing too many
extra warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: fix mipsdsp_trunc16_sat16_round
Petar Jovanovic [Sun, 30 Jun 2013 23:54:47 +0000 (01:54 +0200)]
target-mips: fix mipsdsp_trunc16_sat16_round

This change corrects rounding and saturation of Q31 fractional value in
mipsdsp_trunc16_sat16_round(). Overflow detection was incorrect for the
corner case for PRECRQ_RS.PH, and this test case is also part of the change.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agohw/mips: align initrd to 64KB to avoid kernel error
James Hogan [Thu, 27 Jun 2013 07:35:27 +0000 (08:35 +0100)]
hw/mips: align initrd to 64KB to avoid kernel error

The Linux kernel can be configured to use 64KB pages, but it also
requires initrd to be page aligned. Therefore, to be safe, align the
initrd to 64KB using a new INITRD_PAGE_MASK rather than
TARGET_PAGE_MASK.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agopflash_cfi01: duplicate status byte from bits 23:16 for 32bit reads
Paul Burton [Fri, 14 Jun 2013 07:30:48 +0000 (08:30 +0100)]
pflash_cfi01: duplicate status byte from bits 23:16 for 32bit reads

The firmware commonly used with MIPS Malta boards (YAMON) reads the
status of the pflash with a 32bit memory access. On real hardware
this results in the status byte being mirrored in the upper 16 bits
of the read value. For example if the status byte is represented by
SS then the hardware reads 0x00SS00SS. The YAMON firmware compares the
status against 32bit values expecting the mirrored value and fails
without it.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: generate SMBUS EEPROM data
Paul Burton [Fri, 14 Jun 2013 07:30:47 +0000 (08:30 +0100)]
mips_malta: generate SMBUS EEPROM data

The malta contains 2 EEPROMs, one containing SPD data for the SDRAM and
another containing board information such as serial number and MAC
address. These are both exposed via the PIIX4 SMBUS. Generating this
data and providing it to smbus_eeprom_init will allow YAMON to read a
serial number for the board and prevent it from warning that the EEPROM
data is invalid.

We already have the contents of the SPD EEPROM which are exposed via
FPGA I2C accesses, this is provided as part of the SMBUS EEPROM data
too for consistency.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: cap BIOS endian swap length at 0x3e0000 bytes
Paul Burton [Fri, 14 Jun 2013 07:30:46 +0000 (08:30 +0100)]
mips_malta: cap BIOS endian swap length at 0x3e0000 bytes

This preserves the final sector of the pflash which is used by YAMON to
hold environment variables. If the endianness of the environment data
is swapped then YAMON will fail to load environment variables from
pflash.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: generate SPD EEPROM data at runtime
Paul Burton [Fri, 14 Jun 2013 07:30:45 +0000 (08:30 +0100)]
mips_malta: generate SPD EEPROM data at runtime

The SPD EEPROM specifies the amount of memory present in the system and
thus its correct contents can only be known at runtime. Calculating
parts of the data on init allows the data to accurately reflect the
amount of target memory present and allow YAMON to boot with an
arbitrary amount of SDRAM.

Where possible the SPD data will favor indicating 2 banks of SDRAM
rather than 1. For example the default 128MB of target memory will be
represented as 2x64MB banks rather than 1x128MB bank. This allows
versions of MIPS BIOS code (such as YAMON 2.22 and older) to boot
despite a bug preventing them from handling a single bank of SDRAM with
the Galileo GT64120 system controller emulated by QEMU.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: correct reading MIPS revision at 0x1fc00010
Paul Burton [Fri, 14 Jun 2013 07:30:44 +0000 (08:30 +0100)]
mips_malta: correct reading MIPS revision at 0x1fc00010

Rather than modifying the BIOS code at its original location, copy it
for the 0x1fc00000 region & modify the copy. This means the original
ROM code is correctly readable at 0x1e000010 whilst the MIPS revision
is readable at 0x1fc00010.

Additionally the code previously operated on target memory which would
later be overwritten by the BIOS image upon CPU reset if the -bios
argument was used to specify the BIOS image. This led to the written
MIPS revision being lost. Copying using rom_copy when -bios is used
fixes this issue.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: fix BIOS endianness swapping
Paul Burton [Fri, 14 Jun 2013 07:30:43 +0000 (08:30 +0100)]
mips_malta: fix BIOS endianness swapping

If the target is little endian (mipsel) then the BIOS image endianness
is swapped so that the big endian BIOS binaries commonly produced can be
loaded correctly.

When using the -bios argument the BIOS is loaded using
load_image_targphys, however this doesn't perform the load to target
memory immediately. Instead it loads the BIOS file into a struct Rom
which will later be written to target memory upon reset. However the
endianness conversion was being performed before this, on init, and
operating on the target memory which at this point is blank & will later
be overwritten by the (big endian) BIOS image. Correct this by operating
on the data referenced by struct Rom rather than the target memory when
the -bios argument is used.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agomips_malta: QOM cast cleanup
Andreas Färber [Sat, 27 Jul 2013 20:19:54 +0000 (22:19 +0200)]
mips_malta: QOM cast cleanup

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: fix branch in likely delay slot tcg assert
James Hogan [Mon, 24 Jun 2013 16:45:39 +0000 (17:45 +0100)]
target-mips: fix branch in likely delay slot tcg assert

When a branch delay slot contains another branch instruction, the code
generated raises an exception, however since is_branch==1,
handle_delay_slot() doesn't get called immediately. This means
ctx->bstate isn't set to BS_BRANCH, and the decoder continues decoding
until a non-branch instruction is found.

If the first branch was a branch likely instruction then each
instruction after it generates code for the unlikely case, to go to the
next tb starting after the delay slot. This results in multiple goto_tb
tcg ops being generated with the same exit number. When debug is enabled
this hits:

tcg-op.h:2589: tcg_gen_goto_tb: Assertion `(tcg_ctx.goto_tb_issue_mask & (1 << idx)) == 0' failed.

This is fixed by removing is_branch entirely, and calling
handle_delay_slot() if (ctx.hflags & MIPS_HFLAG_BMASK) was set prior to
the current instruction being decoded. This still prevents
handle_delay_slot() being called immediately after a branch but allows
it to still be called after a branch within a delay slot.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: fix multiplication in mipsdsp_rndq15_mul_q15_q15
Petar Jovanovic [Thu, 23 May 2013 17:37:53 +0000 (19:37 +0200)]
target-mips: fix multiplication in mipsdsp_rndq15_mul_q15_q15

Multiplication of Q15 fractional halfword vectors was incorrect in the
previous implementation of mipsdsp_rndq15_mul_q15_q15. It failed to take
element signs into account. This change fixes it, and it adds a test case
for it.

The change also removes unnecessary cast in the function
mipsdsp_mul_q15_q15_overflowflag21().

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Remove assignment to a variable which is never used
Stefan Weil [Thu, 25 Jul 2013 20:10:31 +0000 (22:10 +0200)]
target-mips: Remove assignment to a variable which is never used

This assignment causes a compiler warning for compilations with the compiler
option -Wunused-but-set-variable (which is included with -Wextra).

Removing it allows using -Wextra for QEMU code without suppressing too many
extra warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agomisc: Use g_assert_not_reached for code which is expected to be unreachable
Stefan Weil [Thu, 25 Jul 2013 16:21:28 +0000 (18:21 +0200)]
misc: Use g_assert_not_reached for code which is expected to be unreachable

The macro g_assert_not_reached is a better self documenting replacement
for assert(0) or assert(false).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agoqemu-options: mention C-a h in the -nographic doc
Ramkumar Ramachandra [Sat, 20 Jul 2013 11:23:09 +0000 (16:53 +0530)]
qemu-options: mention C-a h in the -nographic doc

Otherwise, a new user will be wondering how to switch between the
console and monitor.

Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agomisc: Fix new typos in comments and strings
Stefan Weil [Wed, 24 Jul 2013 17:48:56 +0000 (19:48 +0200)]
misc: Fix new typos in comments and strings

All these typos were found by codespell.

sould -> should
emperical -> empirical
intialization -> initialization
successfuly -> successfully
gaurantee -> guarantee

Fix also another error (before before) in the same context.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agolinux-user: correct argument number for sys_mremap and sys_splice
Petar Jovanovic [Tue, 23 Jul 2013 17:00:10 +0000 (19:00 +0200)]
linux-user: correct argument number for sys_mremap and sys_splice

sys_mremap missed 5th argument (new_address), which caused examples that
remap to a specific address to fail.
sys_splice missed 5th and 6th argument which caused different examples to
fail.
This change has an effect on MIPS target only.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agoPPC: dbdma: macio: Fix format specifiers (build regression)
Stefan Weil [Fri, 12 Jul 2013 16:48:39 +0000 (18:48 +0200)]
PPC: dbdma: macio: Fix format specifiers (build regression)

Fix a number of warnings for 32 bit builds (tested on MingW and Linux):

  CC    hw/ide/macio.o
qemu/hw/ide/macio.c: In function 'pmac_ide_atapi_transfer_cb':
qemu/hw/ide/macio.c:134:9: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'hwaddr' [-Werror=format]
qemu/hw/ide/macio.c: In function 'pmac_ide_transfer_cb':
qemu/hw/ide/macio.c:215:5: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'int64_t' [-Werror=format]
qemu/hw/ide/macio.c:222:9: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'hwaddr' [-Werror=format]
qemu/hw/ide/macio.c:264:9: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'hwaddr' [-Werror=format]
cc1: all warnings being treated as errors
make: *** [hw/ide/macio.o] Error 1

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agowatchdog: Remove break after exit
Stefan Weil [Tue, 23 Jul 2013 04:46:49 +0000 (06:46 +0200)]
watchdog: Remove break after exit

This was dead code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agoexec: Remove env from list of poisoned names
Stefan Weil [Sun, 21 Jul 2013 14:43:14 +0000 (16:43 +0200)]
exec: Remove env from list of poisoned names

The global variable env was removed some time ago, so this name may be
used without any restriction now.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agohw/9pfs: Fix potential memory leak and avoid reuse of freed memory
Stefan Weil [Sun, 16 Jun 2013 10:14:36 +0000 (12:14 +0200)]
hw/9pfs: Fix potential memory leak and avoid reuse of freed memory

The leak was reported by cppcheck.

Function proxy_init also calls g_free for ctx->fs_root.
Avoid reuse of this memory by setting ctx->fs_root to NULL.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agotimer: make timers_state static
Liu Ping Fan [Sun, 21 Jul 2013 08:43:00 +0000 (08:43 +0000)]
timer: make timers_state static

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agoaes: Remove unused code (NDEBUG, u16)
Stefan Weil [Sat, 29 Jun 2013 15:10:48 +0000 (15:10 +0000)]
aes: Remove unused code (NDEBUG, u16)

The current code includes assert.h very early (from qemu-common.h),
so the definition of NDEBUG was without any effect.

In the initial version from 2004, NDEBUG was used to disable the assertions.
Those assertions are not in time critical code, so it is no longer
reasonable to disable them and the definition of NDEBUG can be removed.

Type u16 is also unused and therefore does not need a type definition.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
11 years agoMerge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging
Anthony Liguori [Fri, 26 Jul 2013 22:53:19 +0000 (17:53 -0500)]
Merge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging

QOM CPUState refactorings

* Fix cpu_memory_rw_debug() breakage in s390x KVM
* Replace final CPUArchState in sysemu/kvm.h
* Introduce model subclasses for XtensaCPU
* Introduce CPUClass::gdb_num[_core]_regs
* Introduce CPUClass::gdb_core_xml_file
* Introduce CPUClass::gdb_{read,write}_register()
* Propagate CPUState further in gdbstub

# gpg: Signature made Fri 26 Jul 2013 05:04:28 PM CDT using RSA key ID 3E7E013F
# gpg: Can't check signature: public key not found

# By Andreas Färber (23) and others
# Via Andreas Färber
* afaerber/tags/qom-cpu-for-anthony: (25 commits)
  cpu: Introduce CPUClass::gdb_core_xml_file for GDB_CORE_XML
  target-cris: Factor out CPUClass::gdb_read_register() hook for v10
  cpu: Introduce CPUClass::gdb_{read,write}_register()
  gdbstub: Replace GET_REG*() macros with gdb_get_reg*() functions
  target-xtensa: Move cpu_gdb_{read,write}_register()
  target-lm32: Move cpu_gdb_{read,write}_register()
  target-s390x: Move cpu_gdb_{read,write}_register()
  target-alpha: Move cpu_gdb_{read,write}_register()
  target-cris: Move cpu_gdb_{read,write}_register()
  target-microblaze: Move cpu_gdb_{read,write}_register()
  target-sh4: Move cpu_gdb_{read,write}_register()
  target-openrisc: Move cpu_gdb_{read,write}_register()
  target-mips: Move cpu_gdb_{read,write}_register()
  target-m68k: Move cpu_gdb_{read,write}_register()
  target-arm: Move cpu_gdb_{read,write}_register()
  target-sparc: Move cpu_gdb_{read,write}_register()
  target-ppc: Move cpu_gdb_{read,write}_register()
  target-i386: Move cpu_gdb_{read,write}_register()
  cpu: Introduce CPUState::gdb_num_regs and CPUClass::gdb_num_core_regs
  gdbstub: Drop dead code in cpu_gdb_{read,write}_register()
  ...

11 years agocpu: Introduce CPUClass::gdb_core_xml_file for GDB_CORE_XML
Andreas Färber [Sun, 7 Jul 2013 13:08:22 +0000 (15:08 +0200)]
cpu: Introduce CPUClass::gdb_core_xml_file for GDB_CORE_XML

Replace the GDB_CORE_XML define in gdbstub.c with a CPUClass field.
Use first_cpu for qSupported and qXfer:features:read: for now.
Add a stub for xml_builtin.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-cris: Factor out CPUClass::gdb_read_register() hook for v10
Andreas Färber [Sun, 7 Jul 2013 12:39:41 +0000 (14:39 +0200)]
target-cris: Factor out CPUClass::gdb_read_register() hook for v10

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Introduce CPUClass::gdb_{read,write}_register()
Andreas Färber [Sat, 29 Jun 2013 02:18:45 +0000 (04:18 +0200)]
cpu: Introduce CPUClass::gdb_{read,write}_register()

Completes migration of target-specific code to new target-*/gdbstub.c.

Acked-by: Michael Walle <michael@walle.cc> (for lm32)
Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa)
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agogdbstub: Replace GET_REG*() macros with gdb_get_reg*() functions
Andreas Färber [Sun, 7 Jul 2013 11:05:05 +0000 (13:05 +0200)]
gdbstub: Replace GET_REG*() macros with gdb_get_reg*() functions

This avoids polluting the global namespace with a non-prefixed macro and
makes it obvious in the call sites that we return.

Semi-automatic conversion using, e.g.,
 sed -i 's/GET_REGL(/return gdb_get_regl(mem_buf, /g' target-*/gdbstub.c
followed by manual tweaking for sparc's GET_REGA() and Coding Style.

Acked-by: Michael Walle <michael@walle.cc> (for lm32)
Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa)
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-xtensa: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:57:38 +0000 (12:57 +0200)]
target-xtensa: Move cpu_gdb_{read,write}_register()

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-lm32: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:55:44 +0000 (12:55 +0200)]
target-lm32: Move cpu_gdb_{read,write}_register()

Acked-by: Michael Walle <michael@walle.cc>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-s390x: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:54:12 +0000 (12:54 +0200)]
target-s390x: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-alpha: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:52:32 +0000 (12:52 +0200)]
target-alpha: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-cris: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:50:22 +0000 (12:50 +0200)]
target-cris: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-microblaze: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:45:47 +0000 (12:45 +0200)]
target-microblaze: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-sh4: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:42:52 +0000 (12:42 +0200)]
target-sh4: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-openrisc: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:40:38 +0000 (12:40 +0200)]
target-openrisc: Move cpu_gdb_{read,write}_register()

Reviewed-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agosun4m: add display width and height to the firmware configuration
Mark Cave-Ayland [Fri, 26 Jul 2013 20:42:51 +0000 (21:42 +0100)]
sun4m: add display width and height to the firmware configuration

Currently the graphics resolution for TCX is fixed at 1024x768, however
other framebuffers are capable of supporting additional resolutions.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Anthony Liguori <aliguori@us.ibm.com>
CC: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Fri, 26 Jul 2013 21:54:19 +0000 (16:54 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

# By Kevin Wolf (16) and Ian Main (2)
# Via Kevin Wolf
* kwolf/for-anthony:
  Add tests for sync modes 'TOP' and 'NONE'
  Implement sync modes for drive-backup.
  Implement qdict_flatten()
  blockdev: Split up 'cache' option
  blockdev: Rename 'readonly' option to 'read-only'
  qcow2: Use dashes instead of underscores in options
  blockdev: Rename I/O throttling options for QMP
  QemuOpts: Add qemu_opt_unset()
  block: Allow "driver" option on the top level
  qapi: Anonymous unions
  qapi.py: Maintain a list of union types
  qapi: Add consume argument to qmp_input_get_object()
  qapi: Flat unions with arbitrary discriminator
  qapi: Add visitor for implicit structs
  docs: Document QAPI union types
  qapi-visit.py: Implement 'base' for unions
  qapi-visit.py: Split off generate_visit_struct_fields()
  qapi-types.py: Implement 'base' for unions

Message-id: 1374870032-31672-1-git-send-email-kwolf@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoseccomp: removing unused syscalls gtom whitelist
Eduardo Otubo [Mon, 22 Jul 2013 18:33:37 +0000 (15:33 -0300)]
seccomp: removing unused syscalls gtom whitelist

v3 update:
 - reincluding getrlimit(), it is used by Xen.

v2 update:
 - reincluding setrlimit(), it is used by Xen.

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1374518017-10424-3-git-send-email-otubo@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoseccomp: no need to check arch in syscall whitelist
Eduardo Otubo [Mon, 22 Jul 2013 18:33:36 +0000 (15:33 -0300)]
seccomp: no need to check arch in syscall whitelist

v2 update:
- set libseccomp 2.1.0 as requirement on configure script.

Since libseccomp 2.0 there's no need to check the architecture type
anymore.

Signed-off-by: Eduardo Otubo <otubo@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1374518017-10424-2-git-send-email-otubo@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agotarget-mips: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:38:42 +0000 (12:38 +0200)]
target-mips: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-m68k: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:33:56 +0000 (12:33 +0200)]
target-m68k: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-arm: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:32:15 +0000 (12:32 +0200)]
target-arm: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-sparc: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:29:26 +0000 (12:29 +0200)]
target-sparc: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-ppc: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:26:33 +0000 (12:26 +0200)]
target-ppc: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Move cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 10:07:54 +0000 (12:07 +0200)]
target-i386: Move cpu_gdb_{read,write}_register()

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Introduce CPUState::gdb_num_regs and CPUClass::gdb_num_core_regs
Andreas Färber [Fri, 28 Jun 2013 21:18:47 +0000 (23:18 +0200)]
cpu: Introduce CPUState::gdb_num_regs and CPUClass::gdb_num_core_regs

CPUState::gdb_num_regs replaces num_g_regs.
CPUClass::gdb_num_core_regs replaces NUM_CORE_REGS.

Allows building gdb_register_coprocessor() for xtensa, too.

As a side effect this should fix coprocessor register numbering for SMP.

Acked-by: Michael Walle <michael@walle.cc> (for lm32)
Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa)
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agogdbstub: Drop dead code in cpu_gdb_{read,write}_register()
Andreas Färber [Sun, 7 Jul 2013 09:52:52 +0000 (11:52 +0200)]
gdbstub: Drop dead code in cpu_gdb_{read,write}_register()

GET_REG*() macros include a return statement, thus no need for break.

Acked-by: Michael Walle <michael@walle.cc> (for lm32)
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agogdbstub: Fix cpu_gdb_{read,write}_register() Coding Style
Andreas Färber [Sun, 7 Jul 2013 09:17:26 +0000 (11:17 +0200)]
gdbstub: Fix cpu_gdb_{read,write}_register() Coding Style

Add braces, replace tabs, remove trailing whitespace, drop space before
parenthesis and place break etc. below case statements.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-xtensa: Introduce XtensaCPU subclasses
Andreas Färber [Sat, 6 Jul 2013 23:47:51 +0000 (01:47 +0200)]
target-xtensa: Introduce XtensaCPU subclasses

Register a CPU type per core registered. Save the XtensaConfig in
XtensaCPUClass and copy it from there to CPUXtensaState, to avoid
touching every env->config access for now.

Prepares for storing per-class GDB register count.

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-s390x: Fix CPUState rework fallout
Christian Borntraeger [Fri, 26 Jul 2013 15:48:06 +0000 (17:48 +0200)]
target-s390x: Fix CPUState rework fallout

Commit f17ec444c3d39f76bcd8b71c2c05d5754bfe333e
exec: Change cpu_memory_rw_debug() argument to CPUState

missed to update s390x KVM code, breaking the build.

Let's fix it up.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agokvm: Change prototype of kvm_update_guest_debug()
Stefan Weil [Thu, 25 Jul 2013 18:50:21 +0000 (20:50 +0200)]
kvm: Change prototype of kvm_update_guest_debug()

Passing a CPUState pointer instead of a CPUArchState pointer eliminates
the last target dependent data type in sysemu/kvm.h.

It also simplifies the code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agolinux-user: Avoid redundant ENV_GET_CPU()
Andreas Färber [Fri, 26 Jul 2013 14:42:25 +0000 (16:42 +0200)]
linux-user: Avoid redundant ENV_GET_CPU()

This fixes a mismerge in 874ec3c5b3821bb964f9f37b2f930f2a9ce51652.

Acked-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoAdd tests for sync modes 'TOP' and 'NONE'
Ian Main [Fri, 26 Jul 2013 18:39:05 +0000 (11:39 -0700)]
Add tests for sync modes 'TOP' and 'NONE'

This patch adds tests for sync modes top and none.  Test for 'TOP'
is separated out as it requires a backing file.  Also added a test
for invalid format.

Signed-off-by: Ian Main <imain@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoImplement sync modes for drive-backup.
Ian Main [Fri, 26 Jul 2013 18:39:04 +0000 (11:39 -0700)]
Implement sync modes for drive-backup.

This patch adds sync-modes to the drive-backup interface and
implements the FULL, NONE and TOP modes of synchronization.

FULL performs as before copying the entire contents of the drive
while preserving the point-in-time using CoW.
NONE only copies new writes to the target drive.
TOP copies changes to the topmost drive image and preserves the
point-in-time using CoW.

For sync mode TOP are creating a new target image using the same backing
file as the original disk image.  Then any new data that has been laid
on top of it since creation is copied in the main backup_run() loop.
There is an extra check in the 'TOP' case so that we don't bother to copy
all the data of the backing file as it already exists in the target.
This is where the bdrv_co_is_allocated() is used to determine if the
data exists in the topmost layer or below.

Also any new data being written is intercepted via the write_notifier
hook which ends up calling backup_do_cow() to copy old data out before
it gets overwritten.

For mode 'NONE' we create the new target image and only copy in the
original data from the disk image starting from the time the call was
made.  This preserves the point in time data by only copying the parts
that are *going to change* to the target image.  This way we can
reconstruct the final image by checking to see if the given block exists
in the new target image first, and if it does not, you can get it from
the original image.  This is basically an optimization allowing you to
do point-in-time snapshots with low overhead vs the 'FULL' version.

Since there is no old data to copy out the loop in backup_run() for the
NONE case just calls qemu_coroutine_yield() which only wakes up after
an event (usually cancel in this case).  The rest is handled by the
before_write notifier which again calls backup_do_cow() to write out
the old data so it can be preserved.

Signed-off-by: Ian Main <imain@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoImplement qdict_flatten()
Kevin Wolf [Mon, 8 Jul 2013 15:11:58 +0000 (17:11 +0200)]
Implement qdict_flatten()

qdict_flatten(): For each nested QDict with key x, all fields with key y
are moved to this QDict and their key is renamed to "x.y". This operation
is applied recursively for nested QDicts.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoblockdev: Split up 'cache' option
Kevin Wolf [Thu, 18 Jul 2013 14:31:25 +0000 (16:31 +0200)]
blockdev: Split up 'cache' option

The old 'cache' option really encodes three different boolean flags into
a cache mode name, without providing all combinations. Make them three
separate options instead and translate the old option to the new ones
for drive_init().

The specific boolean options take precedence if the old cache option is
specified as well, so the following options are equivalent:

-drive file=x,cache=none,cache.no-flush=true
-drive file=x,cache.writeback=true,cache.direct=true,cache.no-flush=true

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoblockdev: Rename 'readonly' option to 'read-only'
Kevin Wolf [Fri, 19 Jul 2013 18:07:29 +0000 (20:07 +0200)]
blockdev: Rename 'readonly' option to 'read-only'

Option name cleanup before it becomes a QMP API.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqcow2: Use dashes instead of underscores in options
Kevin Wolf [Wed, 17 Jul 2013 12:45:34 +0000 (14:45 +0200)]
qcow2: Use dashes instead of underscores in options

This is what QMP wants to use. The options haven't been enabled in any
release yet, so we're still free to change them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoblockdev: Rename I/O throttling options for QMP
Kevin Wolf [Wed, 17 Jul 2013 12:41:54 +0000 (14:41 +0200)]
blockdev: Rename I/O throttling options for QMP

In QMP, we want to use dashes instead of underscores in QMP argument
names, and use nested options for throttling.

The new option names affect the command line as well, but for
compatibility drive_init() will convert the old option names before
calling into the code that will be shared between -drive and
blockdev-add.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoQemuOpts: Add qemu_opt_unset()
Kevin Wolf [Wed, 17 Jul 2013 12:40:37 +0000 (14:40 +0200)]
QemuOpts: Add qemu_opt_unset()

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoblock: Allow "driver" option on the top level
Kevin Wolf [Tue, 9 Jul 2013 09:09:02 +0000 (11:09 +0200)]
block: Allow "driver" option on the top level

This is traditionally -drive format=..., which is now translated into
the new driver option. This gives us a more consistent way to select the
driver of BlockDriverStates that can be used in QMP context, too.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi: Anonymous unions
Kevin Wolf [Mon, 8 Jul 2013 14:14:21 +0000 (16:14 +0200)]
qapi: Anonymous unions

The discriminator for anonymous unions is the data type. This allows to
have a union type that allows both of these:

    { 'file': 'my_existing_block_device_id' }
    { 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } }

Unions like this are specified in the schema with an empty dict as
discriminator. For this example you could take:

    { 'union': 'BlockRef',
      'discriminator': {},
      'data': { 'definition': 'BlockOptions',
                'reference': 'str' } }
    { 'type': 'ExampleObject',
      'data: { 'file': 'BlockRef' } }

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi.py: Maintain a list of union types
Kevin Wolf [Tue, 16 Jul 2013 08:49:41 +0000 (10:49 +0200)]
qapi.py: Maintain a list of union types

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi: Add consume argument to qmp_input_get_object()
Kevin Wolf [Mon, 8 Jul 2013 09:33:07 +0000 (11:33 +0200)]
qapi: Add consume argument to qmp_input_get_object()

This allows to just look at the next element without actually consuming
it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi: Flat unions with arbitrary discriminator
Kevin Wolf [Wed, 3 Jul 2013 13:58:57 +0000 (15:58 +0200)]
qapi: Flat unions with arbitrary discriminator

Instead of the rather verbose syntax that distinguishes base and
subclass fields...

  { "type": "file",
    "read-only": true,
    "data": {
        "filename": "test"
    } }

...we can now have both in the same namespace, allowing a more direct
mapping of the command line, and moving fields between the common base
and subclasses without breaking the API:

  { "driver": "file",
    "read-only": true,
    "filename": "test" }

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi: Add visitor for implicit structs
Kevin Wolf [Wed, 3 Jul 2013 13:52:42 +0000 (15:52 +0200)]
qapi: Add visitor for implicit structs

These can be used when an embedded struct is parsed and members not
belonging to the struct may be present in the input (e.g. parsing a
flat namespace QMP union, where fields from both the base and one
of the alternative types are mixed in the JSON object)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agodocs: Document QAPI union types
Kevin Wolf [Tue, 16 Jul 2013 11:17:27 +0000 (13:17 +0200)]
docs: Document QAPI union types

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi-visit.py: Implement 'base' for unions
Kevin Wolf [Tue, 2 Jul 2013 14:20:04 +0000 (16:20 +0200)]
qapi-visit.py: Implement 'base' for unions

This implements the visitor part of base types for unions. Parsed into
QMP, this example schema definition...

    { 'type': 'BlockOptionsBase', 'data': { 'read-only': 'bool' } }
    { 'type': 'BlockOptionsQcow2, 'data': { 'lazy-refcounts': 'bool' } }

    { 'union': 'BlockOptions',
      'base': 'BlockOptionsBase',
      'data': {
          'raw': 'BlockOptionsRaw'
          'qcow2': 'BlockOptionsQcow2'
      } }

...would describe the following JSON object:

    { "type": "qcow2",
      "read-only": true,
      "data": { "lazy-refcounts": false } }

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi-visit.py: Split off generate_visit_struct_fields()
Kevin Wolf [Tue, 2 Jul 2013 14:18:35 +0000 (16:18 +0200)]
qapi-visit.py: Split off generate_visit_struct_fields()

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoqapi-types.py: Implement 'base' for unions
Kevin Wolf [Tue, 2 Jul 2013 10:18:47 +0000 (12:18 +0200)]
qapi-types.py: Implement 'base' for unions

The new 'base' key in a union definition refers to a struct type, which
is inlined into the union definition and can represent fields common to
all kinds.

For example the following schema definition...

    { 'type': 'BlockOptionsBase', 'data': { 'read-only': 'bool' } }

    { 'union': 'BlockOptions',
      'base': 'BlockOptionsBase',
      'data': {
          'raw': 'BlockOptionsRaw'
          'qcow2': 'BlockOptionsQcow2'
      } }

...would result in this generated C struct:

    struct BlockOptions
    {
        BlockOptionsKind kind;
        union {
            void *data;
            BlockOptionsRaw * raw;
            BlockOptionsQcow2 * qcow2;
        };
        bool read_only;
    };

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
11 years agoMerge remote-tracking branch 'rth/tcg-next' into staging
Anthony Liguori [Fri, 26 Jul 2013 18:04:21 +0000 (13:04 -0500)]
Merge remote-tracking branch 'rth/tcg-next' into staging

# By Claudio Fontana (1) and others
# Via Richard Henderson
* rth/tcg-next:
  tcg: Remove temp_buf
  tcg/aarch64: Implement tlb lookup fast path
  tcg/aarch64: implement ldst 12bit scaled uimm offset

Message-id: 1373919944-8521-1-git-send-email-rth@twiddle.net
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'jliu/or32' into staging
Anthony Liguori [Fri, 26 Jul 2013 18:04:07 +0000 (13:04 -0500)]
Merge remote-tracking branch 'jliu/or32' into staging

# By Jia Liu
# Via Jia Liu
* jliu/or32:
  target-openrisc: Free typename in openrisc_cpu_class_by_name
  hw/openrisc: Use stderr output instead of qemu_log
  hw/openrisc: Indent typo

Message-id: 1374576458-22808-1-git-send-email-proljc@gmail.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'mdroth/qga-pull-2013-7-25' into staging
Anthony Liguori [Thu, 25 Jul 2013 20:58:29 +0000 (15:58 -0500)]
Merge remote-tracking branch 'mdroth/qga-pull-2013-7-25' into staging

# By Laszlo Ersek
# Via Michael Roth
* mdroth/qga-pull-2013-7-25:
  qga: escape cmdline args when registering win32 service (CVE-2013-2231)
  ga_install_service(): nest error paths more idiomatically
  qga/service-win32.c: diagnostic output should go to stderr

Message-id: 1374784644-29078-1-git-send-email-mdroth@linux.vnet.ibm.com

11 years agoMerge remote-tracking branch 'kraxel/seabios-1.7.3' into staging
Anthony Liguori [Thu, 25 Jul 2013 20:56:36 +0000 (15:56 -0500)]
Merge remote-tracking branch 'kraxel/seabios-1.7.3' into staging

# By Gerd Hoffmann
# Via Gerd Hoffmann
* kraxel/seabios-1.7.3:
  seabios: update to 1.7.3

Message-id: 1374673573-25074-1-git-send-email-kraxel@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'riku/linux-user-for-upstream' into staging
Anthony Liguori [Thu, 25 Jul 2013 20:56:06 +0000 (15:56 -0500)]
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging

* riku/linux-user-for-upstream: (21 commits)
  linux-user: Handle compressed ISA encodings when processing MIPS exceptions
  linux-user: Unlock mmap_lock when resuming guest from page_unprotect
  linux-user: Reset copied CPUs in cpu_copy() always
  linux-user: Fix epoll on ARM hosts
  linux-user: fix segmentation fault passing with h2g(x) != x
  linux-user: Fix pipe syscall return for SPARC
  linux-user: Fix target_stat and target_stat64 for OpenRISC
  linux-user: Avoid conditional cpu_reset()
  configure: Make NPTL non-optional
  linux-user: Enable NPTL for x86-64
  linux-user: Add i386 TLS setter
  linux-user: Clean up handling of clone() argument order
  linux-user: Add missing 'break' in i386 get_thread_area syscall
  linux-user: Enable NPTL for m68k
  linux-user: Enable NPTL for SPARC targets
  linux-user: Enable NPTL for OpenRISC
  linux-user: Move includes of target-specific headers to end of qemu.h
  configure: Enable threading for unicore32-linux-user
  configure: Enable threading on all ppc and mips linux-user targets
  configure: Don't say target_nptl="no" if there is no linux-user target
  ...

Conflicts:
linux-user/main.c

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoqga: escape cmdline args when registering win32 service (CVE-2013-2231)
Laszlo Ersek [Wed, 3 Jul 2013 13:14:10 +0000 (15:14 +0200)]
qga: escape cmdline args when registering win32 service (CVE-2013-2231)

Reported-by: Lev Veyde <lveyde@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoga_install_service(): nest error paths more idiomatically
Laszlo Ersek [Wed, 3 Jul 2013 13:14:09 +0000 (15:14 +0200)]
ga_install_service(): nest error paths more idiomatically

Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqga/service-win32.c: diagnostic output should go to stderr
Laszlo Ersek [Wed, 3 Jul 2013 13:14:08 +0000 (15:14 +0200)]
qga/service-win32.c: diagnostic output should go to stderr

Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>