OSDN Git Service

qmiga/qemu.git
10 years agotarget-arm: Introduce per-CPU field for PSCI version
Pranavkumar Sawargaonkar [Thu, 19 Jun 2014 17:06:26 +0000 (18:06 +0100)]
target-arm: Introduce per-CPU field for PSCI version

We require to know the PSCI version available to given CPU at
potentially many places. Currently, we need to know PSCI version
when generating DTB for virt machine.

This patch introduce per-CPU 32bit field representing the PSCI
version available to the CPU. The encoding of this 32bit field
is same as described in PSCI v0.2 spec.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1402901605-24551-8-git-send-email-pranavkumar@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64
Pranavkumar Sawargaonkar [Thu, 19 Jun 2014 17:06:26 +0000 (18:06 +0100)]
target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64

To implement kvm_arch_reset_vcpu(), we simply re-init the VCPU
using kvm_arm_vcpu_init() so that all registers of VCPU are set
to their reset values by in-kernel KVM code.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1402901605-24551-7-git-send-email-pranavkumar@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible
Pranavkumar Sawargaonkar [Thu, 19 Jun 2014 17:06:26 +0000 (18:06 +0100)]
target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible

Latest linux kernel supports in-kernel emulation of PSCI v0.2 but
to enable it we need to select KVM_ARM_VCPU_PSCI_0_2 feature using
KVM_ARM_VCPU_INIT ioctl.

Also, we can use KVM_ARM_VCPU_PSCI_0_2 feature for VCPU only when
linux kernel has KVM_CAP_ARM_PSCI_0_2 capability.

This patch updates kvm_arch_init_vcpu() to enable KVM_ARM_VCPU_PSCI_0_2
feature for VCPU when KVM ARM/ARM64 has KVM_CAP_ARM_PSCI_0_2 capability.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1402901605-24551-6-git-send-email-pranavkumar@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64
Pranavkumar Sawargaonkar [Thu, 19 Jun 2014 17:06:26 +0000 (18:06 +0100)]
target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64

Introduce a common kvm_arm_vcpu_init() for doing KVM_ARM_VCPU_INIT
ioctl in KVM ARM and KVM ARM64. This also helps us factor-out few
common code lines from kvm_arch_init_vcpu() for KVM ARM/ARM64.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1402901605-24551-5-git-send-email-pranavkumar@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agokvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT
Pranavkumar Sawargaonkar [Thu, 19 Jun 2014 17:06:25 +0000 (18:06 +0100)]
kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT

In-kernel PSCI v0.2 emulation of KVM ARM/ARM64 forwards SYSTEM_OFF
and SYSTEM_RESET function calls to QEMU using KVM_EXIT_SYSTEM_EVENT
exit reason.

This patch updates kvm_cpu_exec() to handle KVM_SYSTEM_EVENT_SHUTDOWN
and KVM_SYSTEM_EVENT_RESET system-level events from QEMU-side.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1402901605-24551-4-git-send-email-pranavkumar@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agohw/block/pflash_cfi01: Report correct size info for parallel configs
Peter Maydell [Thu, 19 Jun 2014 17:06:25 +0000 (18:06 +0100)]
hw/block/pflash_cfi01: Report correct size info for parallel configs

If the flash device is configured with a device-width which is
not equal to the bank-width, indicating that it is actually several
narrow flash devices in parallel, the CFI table should report the
number of blocks and the size of a single device, not of the whole
combined setup. This stops Linux from complaining:
"NOR chip too large to fit in mapping. Attempting to cope..."

As usual, we retain the old broken but backwards compatible behaviour
when the device-width is not specified.

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1402409025-25694-1-git-send-email-peter.maydell@linaro.org

10 years agohw/arm/vexpress: Forbid specifying flash contents in two ways at once
Peter Maydell [Thu, 19 Jun 2014 17:06:25 +0000 (18:06 +0100)]
hw/arm/vexpress: Forbid specifying flash contents in two ways at once

Detect attempts by the user to specify the contents of the first flash
device via both -bios and -drive if=pflash... simultaneously and
print a helpful error message.

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

10 years agotarget-arm/translate-a64.c: Fix dead ?: in handle_simd_shift_fpint_conv()
Peter Maydell [Thu, 19 Jun 2014 17:06:25 +0000 (18:06 +0100)]
target-arm/translate-a64.c: Fix dead ?: in handle_simd_shift_fpint_conv()

In handle_simd_shift_fpint_conv(), the combination of is_double == true,
is_scalar == false and is_q == false is an unallocated encoding; the
'both parts false' case of the nested ?: expression for calculating
maxpass is therefore unreachable and can be removed.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1402171881-14343-4-git-send-email-peter.maydell@linaro.org

10 years agotarget-arm/translate-a64.c: Remove dead ?: in disas_simd_3same_int()
Peter Maydell [Thu, 19 Jun 2014 17:06:24 +0000 (18:06 +0100)]
target-arm/translate-a64.c: Remove dead ?: in disas_simd_3same_int()

In disas_simd_3same_int(), none of the instructions permit is_q
to be false with size == 3 (this would be a vector operation with
a one-element vector, and the instruction set encodes those as
scalar operations). Replace the always-true ?: check with an
assert.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1402171881-14343-3-git-send-email-peter.maydell@linaro.org

10 years agotarget-arm: Add ULL suffix to calculation of page size
Peter Maydell [Thu, 19 Jun 2014 17:06:24 +0000 (18:06 +0100)]
target-arm: Add ULL suffix to calculation of page size

The maximum block size for AArch64 address translation is 2GB. This means
that we need a ULL suffix on our shift to avoid shifting into the sign
bit of a signed 32 bit integer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1402171881-14343-2-git-send-email-peter.maydell@linaro.org

10 years agohw/arm/spitz: Avoid clash with Windows header symbol MOD_SHIFT
Peter Maydell [Thu, 19 Jun 2014 17:06:24 +0000 (18:06 +0100)]
hw/arm/spitz: Avoid clash with Windows header symbol MOD_SHIFT

The Windows headers provided by MinGW define MOD_SHIFT. Avoid
it by using SPITZ_MOD_* for our constants here.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: implement PD0/PD1 bits for TTBCR
Fabian Aggeler [Thu, 19 Jun 2014 17:06:24 +0000 (18:06 +0100)]
target-arm: implement PD0/PD1 bits for TTBCR

Corrected handling of writes to TTBCR for ARMv8 (previously UNK/SBZP
bits are not RES0) and ARMv7 (new bits PD0/PD1 for CPUs with Security
Extensions).

Bits PD0/PD1 are now respected in get_phys_addr_v6/v5() and
get_level1_table_address.

Signed-off-by: Fabian Aggeler <aggelerf@ethz.ch>
Message-id: 1402409556-18574-1-git-send-email-aggelerf@ethz.ch
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/bonzini/scsi-next' into staging
Peter Maydell [Thu, 19 Jun 2014 15:18:04 +0000 (16:18 +0100)]
Merge remote-tracking branch 'remotes/bonzini/scsi-next' into staging

* remotes/bonzini/scsi-next:
  virtio-scsi: define dummy handle_output for vhost-scsi vqs
  block/iscsi: drop obsolete pointers from iscsi_co_writev
  block/iscsi: fix init value for iTask->retries
  block/iscsi: bump libiscsi requirement to 1.9.0
  virtio-scsi: add support for the any_layout feature
  virtio-scsi: introduce virtio_scsi_complete_cmd_req
  virtio-scsi: prepare sense data handling for any_layout
  virtio-scsi: add extra argument and return type to qemu_sgl_concat
  virtio-scsi: add target swap for VirtIOSCSICtrlTMFReq fields
  virtio-scsi: start preparing for any_layout
  util: add return value to qemu_iovec_concat_iov
  megasas: use PCI DMA API
  scsi: Print command name in debug
  scsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c
  scsi-disk.c: Fix compilation with -DDEBUG_SCSI
  block/iscsi: use 16 byte CDBs only when necessary
  block/iscsi: fix potential segfault on early callback
  block/iscsi: handle BUSY condition

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoinclude/qemu/aes.h: Avoid conflicts with FreeBSD AES functions
Sean Bruno [Mon, 16 Jun 2014 15:02:07 +0000 (08:02 -0700)]
include/qemu/aes.h: Avoid conflicts with FreeBSD AES functions

FreeBSD's libcrypto provides functions with the same names as us;
use #define to rename our versions to avoid conflicts at link time.

Signed-off-by: Sean Bruno <sbruno@freebsd.org>
Signed-off-by: Ed Maste <emaste@freebsd.org>
Message-id: 1402930927-41125-1-git-send-email-sbruno@freebsd.org
[PMM: improved commit message, fixed comment typo]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agow32: Fix regression caused by new g_poll implementation
Stefan Weil [Wed, 28 May 2014 15:42:24 +0000 (17:42 +0200)]
w32: Fix regression caused by new g_poll implementation

Commit 5a007547df76446ab891df93ebc55749716609bf tried to fix a
performance degradation caused by bad handling of small timeouts
in the original implementation of g_poll.

Since that commit, hard disk I/O no longer works.

Instead of rewriting the g_poll implementation, this patch simply copies
the original code (released under LGPL) from latest glib and only modifies
it where needed (see comments in the code). URL of the original code:
https://git.gnome.org/browse/glib/tree/glib/gpoll.c

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Message-id: 1401291744-14314-1-git-send-email-sw@weilnetz.de
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agovirtio-scsi: define dummy handle_output for vhost-scsi vqs
Ming Lei [Thu, 19 Jun 2014 08:12:00 +0000 (16:12 +0800)]
virtio-scsi: define dummy handle_output for vhost-scsi vqs

vhost userspace needn't to handle vq's notification from guest,
so define dummy handle_output callback for all vqs of vhost-scsi.

In some corner cases(such as when handling vq's reset from VM), virtio-pci
still trys to handle pending virtio-scsi events, then object check failure
inside virtio_scsi_handle_event() for vhost-scsi can be triggered.

The issue can be reproduced by 'rmmod virtio-scsi', 'system sleep' or reboot
inside VM.

Cc: qemu-stable@nongnu.org
Cc: Anthony Liguori <aliguori@amazon.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoblock/iscsi: drop obsolete pointers from iscsi_co_writev
Peter Lieven [Wed, 18 Jun 2014 16:40:22 +0000 (18:40 +0200)]
block/iscsi: drop obsolete pointers from iscsi_co_writev

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoblock/iscsi: fix init value for iTask->retries
Peter Lieven [Wed, 18 Jun 2014 16:40:11 +0000 (18:40 +0200)]
block/iscsi: fix init value for iTask->retries

during rebasing the changed init value for the
retry counter was missed. This resulted in no retries
being performed at all.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-mips: implement UserLocal Register
Petar Jovanovic [Wed, 18 Jun 2014 15:48:20 +0000 (17:48 +0200)]
target-mips: implement UserLocal Register

From MIPS documentation (Volume III):

UserLocal Register (CP0 Register 4, Select 2)
Compliance Level: Recommended.

The UserLocal register is a read-write register that is not interpreted by
the hardware and conditionally readable via the RDHWR instruction.

This register only exists if the Config3-ULRI register field is set.

Privileged software may write this register with arbitrary information and
make it accessible to unprivileged software via register 29 (ULR) of the
RDHWR instruction. To do so, bit 29 of the HWREna register must be set to a
1 to enable unprivileged access to the register.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
10 years agobitops: provide an inline implementation of find_first_bit
Aurelien Jarno [Sat, 21 Dec 2013 00:15:21 +0000 (01:15 +0100)]
bitops: provide an inline implementation of find_first_bit

find_first_bit has started to be used heavily in TCG code. The current
implementation based on find_next_bit is not optimal and can't be
optimized be the compiler if the bit array has a fixed size, which is
the case most of the time.

This new implementation does not use find_next_bit and is yet small
enough to be inlined.

Cc: Corentin Chary <corentin.chary@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
10 years agoblock/iscsi: bump libiscsi requirement to 1.9.0
Peter Lieven [Wed, 4 Jun 2014 12:33:26 +0000 (14:33 +0200)]
block/iscsi: bump libiscsi requirement to 1.9.0

This patch lifts the minimum supported libiscsi version from 1.4.0 to
1.9.0 since the BUSY patch required that change.

On one this allows us to remove all #ifdefs from the code which
makes the code easier to maintain and read. On the other hand
I would not recommend libiscsi prior to 1.8.0 for production use
because the following important libiscsi fixes for deadlocks and
protocol errors are missing prior to 1.8.0:

dbe9a1e SOCKET queue cmd PDUs directly in waitpdu queue
30df192 DATA-OUT set pdu->cmdsn appropriately
548bd22 ISCSI fix broken send logic in iscsi_scsi_async_command
14bee10 RECONNECT do not increase CmdSN for immediate PDUs
1f4a66a PDU queue out PDUs in order of itt.
562dd46 PDU avoid incrementing itt to 0xffffffff
cd09c0f PDU use serial32 arithmetic for cmdsn, maxcmdsn and expcmdsn.
89e918e SOCKET validate data_size in in_pdu header
91267f5 Limit immediate and unsolicited data to FirstBurstLength

Note that libiscsi 1.9.0 was released on Feb 24th, 2013, about
one month after 1.8.0.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/bonzini/memory' into staging
Peter Maydell [Wed, 18 Jun 2014 14:08:38 +0000 (15:08 +0100)]
Merge remote-tracking branch 'remotes/bonzini/memory' into staging

* remotes/bonzini/memory:
  memory: Don't call memory_region_update_coalesced_range if nothing changed
  memory: MemoryRegion: rename parent to container
  memory: MemoryRegion: factor out memory region re-adder
  memory: MemoryRegion: factor out subregion add functionality
  qtest: fix qtest_clock_warp() for no deadline case
  exec: dummy_section: Pass address space through.
  memory: Simplify mr_add_subregion() if-else
  memory: Don't update all memory region when ioeventfd changed
  unset RAMBlock idstr when unregister MemoryRegion
  exec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr
  MAINTAINERS: Add myself as Memory API maintainer

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agomemory: Don't call memory_region_update_coalesced_range if nothing changed
Fam Zheng [Fri, 13 Jun 2014 06:34:41 +0000 (14:34 +0800)]
memory: Don't call memory_region_update_coalesced_range if nothing changed

With huge number of PCI devices in the system (for example, 200
virtio-blk-pci), this unconditional call can slow down emulation of
irrelevant PCI operations drastically, such as a BAR update on a device
that has no coalescing region. So avoid it.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: MemoryRegion: rename parent to container
Paolo Bonzini [Wed, 11 Jun 2014 09:18:09 +0000 (11:18 +0200)]
memory: MemoryRegion: rename parent to container

Avoid confusion with the QOM parent.

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-scsi: add support for the any_layout feature
Paolo Bonzini [Tue, 10 Jun 2014 14:40:31 +0000 (16:40 +0200)]
virtio-scsi: add support for the any_layout feature

Store the request and response headers by value, and let
virtio_scsi_parse_req check that there is only one of datain
and dataout.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-scsi: introduce virtio_scsi_complete_cmd_req
Paolo Bonzini [Tue, 10 Jun 2014 18:16:20 +0000 (20:16 +0200)]
virtio-scsi: introduce virtio_scsi_complete_cmd_req

This is also related to sense handling, and will be used
by anylayout.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-scsi: prepare sense data handling for any_layout
Paolo Bonzini [Tue, 10 Jun 2014 14:58:19 +0000 (16:58 +0200)]
virtio-scsi: prepare sense data handling for any_layout

Retrieve sense and copy it to guest memory, to prepare for when we will use
qemu_iovec_from_buf.

Swap response and request, since we'll use the tail of VirtIOSCSIReq
for the CDB.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-scsi: add extra argument and return type to qemu_sgl_concat
Paolo Bonzini [Tue, 10 Jun 2014 14:39:24 +0000 (16:39 +0200)]
virtio-scsi: add extra argument and return type to qemu_sgl_concat

Will be used for anylayout support.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-scsi: add target swap for VirtIOSCSICtrlTMFReq fields
Paolo Bonzini [Tue, 10 Jun 2014 14:53:39 +0000 (16:53 +0200)]
virtio-scsi: add target swap for VirtIOSCSICtrlTMFReq fields

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-scsi: start preparing for any_layout
Paolo Bonzini [Tue, 10 Jun 2014 14:21:18 +0000 (16:21 +0200)]
virtio-scsi: start preparing for any_layout

- Introduce virtio_scsi_init_req and virtio_scsi_free_req

- rename qemu_sgl_init_external to qemu_sgl_concat

- move virtio_scsi_parse_req from virtio_scsi_pop_req to callers
  and add header length checks to virtio_scsi_parse_req.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoutil: add return value to qemu_iovec_concat_iov
Paolo Bonzini [Tue, 10 Jun 2014 14:21:28 +0000 (16:21 +0200)]
util: add return value to qemu_iovec_concat_iov

This will be necessary later to recognize the case where a
request has both dataout and datain.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomegasas: use PCI DMA API
Paolo Bonzini [Fri, 13 Jun 2014 15:26:13 +0000 (17:26 +0200)]
megasas: use PCI DMA API

MegaSAS emulation is not IOMMU-friendly.  Fix this by switching to
pci_dma_* functions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi: Print command name in debug
Alexey Kardashevskiy [Thu, 12 Jun 2014 05:41:37 +0000 (15:41 +1000)]
scsi: Print command name in debug

This makes scsi_command_name() public.

This makes use of scsi_command_name() in debug output for scsi-disk and
spapr-vscsi host bus adapter. Before this, SCSI used to print hex numbers
instead of human-friendly strings.

This adds GET_EVENT_STATUS_NOTIFICATION and READ_DISC_INFORMATION to
the list of SCSI commands supported by scsi_command_name().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c
Ulrich Obergfell [Sun, 8 Jun 2014 17:22:33 +0000 (19:22 +0200)]
scsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c

This patch fixes a bug in scsi_block_new_request() that was introduced
by commit 137745c5c60f083ec982fe9e861e8c16ebca1ba8. If the host cache
is used - i.e. if BDRV_O_NOCACHE is _not_ set - the 'break' statement
needs to be executed to 'fall back' to SG_IO.

Cc: qemu-stable@nongnu.org
Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi-disk.c: Fix compilation with -DDEBUG_SCSI
Paul Janzen [Thu, 5 Jun 2014 05:33:40 +0000 (22:33 -0700)]
scsi-disk.c: Fix compilation with -DDEBUG_SCSI

In scsi-disk.c, if you #define DEBUG_SCSI=1, you get:
hw/scsi/scsi-disk.c: In function 'scsi_disk_emulate_command':
hw/scsi/scsi-disk.c:2018: error: 'SCSIRequest' has no member named 'buf'

Change the debugging statement to match the actual value tested.

Signed-off-by: Paul Janzen <pcj@pauljanzen.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoblock/iscsi: use 16 byte CDBs only when necessary
Peter Lieven [Wed, 4 Jun 2014 13:47:39 +0000 (15:47 +0200)]
block/iscsi: use 16 byte CDBs only when necessary

this patch changes the driver to uses 16 Byte CDBs for
READ/WRITE only if the target requires 64bit lba addressing.

On one hand this saves 6 bytes in each PDU on the other
hand it seems that 10 Byte CDBs seems to be much better
supported and tested as a recent issue I had with a
major storage supplier lined out.

For WRITESAME the logic is a bit more tricky as WRITESAME10
with UNMAP was added really late. Thus a fallback to WRITESAME16
is possible if it supports UNMAP and WRITESAME10 not.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoblock/iscsi: fix potential segfault on early callback
Peter Lieven [Tue, 10 Jun 2014 07:52:16 +0000 (09:52 +0200)]
block/iscsi: fix potential segfault on early callback

it might happen in the future that a function directly invokes its callback.
In this case we end up in a segfault because the iTask is gone when the BH
is scheduled.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoblock/iscsi: handle BUSY condition
Peter Lieven [Fri, 30 May 2014 21:36:47 +0000 (23:36 +0200)]
block/iscsi: handle BUSY condition

this patch adds handling of BUSY status reponse from an iSCSI target.
Currently, we fail with -EIO in case of SCSI_STATUS_BUSY while the
obvious reaction would be to retry the operation after some time.
The retry time is randomly choosen from a range with exponential
growth increasing with each retry.

This patch includes most of the changes by a an upcoming patch
from Stefan Hajnoczi:

 iscsi: implement .bdrv_detach/attach_aio_context()

because I also need the reference to the aio_context for
the retry timer to work. I included the changes to maintain
better mergeability.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: MemoryRegion: factor out memory region re-adder
Peter Crosthwaite [Fri, 6 Jun 2014 06:15:18 +0000 (23:15 -0700)]
memory: MemoryRegion: factor out memory region re-adder

memory_region_set_address is mostly just a function that deletes and
re-adds a memory region. Factor this generic functionality out into a
re-usable function. This prepares support for further QOMification
of MemoryRegion.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: MemoryRegion: factor out subregion add functionality
Peter Crosthwaite [Fri, 6 Jun 2014 06:14:44 +0000 (23:14 -0700)]
memory: MemoryRegion: factor out subregion add functionality

Split off the core looping code that actually adds subregions into
it's own fn. This prepares support for Memory Region qomification
where setting the MR address or parent via QOM will back onto this more
minimal function.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[Rename new function. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging
Peter Maydell [Tue, 17 Jun 2014 15:08:06 +0000 (16:08 +0100)]
Merge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging

* remotes/riku/linux-user-for-upstream:
  User mode support for Linux ELF files with no section header
  linux-user: Return correct errno for unsupported netlink socket
  linux-user: Don't overrun guest buffer in sched_getaffinity
  linux-user/uname: Return correct uname string for x86_64
  linux-user: fix gcc-4.9 compiler error on __{get,put]}_user
  signal/ppc/do_setcontext remove __get_user return check
  signal/sparc64_set_context: remove __get_user checks
  signal/ppc/{save,restore}_user_regs remove __put/get error checks
  signal/all/setup_frame remove __put_user checks
  signal/all/do_sigreturn - remove __get_user checks
  signal/all/do_sigaltstack remove __get_user value check
  signal/sparc/restore_fpu_state: remove
  signal/all: remove return value from restore_sigcontext
  signal/all: remove return value from setup_sigcontext
  signal/all: remove return value from copy_siginfo_to_user
  signal/x86/setup_frame: __put_user cleanup
  signal/all: remove __get/__put_user return value reading

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoqtest: fix qtest_clock_warp() for no deadline case
Sergey Fedorov [Tue, 10 Jun 2014 09:10:28 +0000 (13:10 +0400)]
qtest: fix qtest_clock_warp() for no deadline case

Use dedicated qemu_soonest_timeout() instead of MIN().

Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: dummy_section: Pass address space through.
Peter Crosthwaite [Tue, 3 Jun 2014 02:08:44 +0000 (19:08 -0700)]
exec: dummy_section: Pass address space through.

Rather than use the global singleton.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Simplify mr_add_subregion() if-else
Peter Crosthwaite [Mon, 12 May 2014 08:13:47 +0000 (01:13 -0700)]
memory: Simplify mr_add_subregion() if-else

This if else is not needed. The previous call to memory_region_add
(whether _overlap or not) will always set priority and may_overlap
to desired values. And its not possible to get here without having
called memory_region_add_subregion due to the null guard on parent.
So we can just directly call memory_region_add_subregion_common.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Don't update all memory region when ioeventfd changed
Gonglei [Thu, 8 May 2014 03:47:32 +0000 (11:47 +0800)]
memory: Don't update all memory region when ioeventfd changed

memory mappings don't rely on ioeventfds, there is no need
to destroy and rebuild them when manipulating ioeventfds,
otherwise it scarifies performance.

according to testing result, each ioeventfd deleing needs
about 5ms, within which memory mapping rebuilding needs
about 4ms. With many Nics and vmchannel in a VM doing migrating,
there can be many ioeventfds deleting which increasing
downtime remarkably.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Herongguang <herongguang.he@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agounset RAMBlock idstr when unregister MemoryRegion
Hu Tao [Wed, 2 Apr 2014 07:13:27 +0000 (15:13 +0800)]
unset RAMBlock idstr when unregister MemoryRegion

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr
Hu Tao [Wed, 2 Apr 2014 07:13:26 +0000 (15:13 +0800)]
exec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMAINTAINERS: Add myself as Memory API maintainer
Paolo Bonzini [Tue, 29 Apr 2014 14:05:53 +0000 (16:05 +0200)]
MAINTAINERS: Add myself as Memory API maintainer

I'm not including Avi since he has already removed himself from the
KVM entry.  I'm not going to commit my patches without review.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoUser mode support for Linux ELF files with no section header
Craig Heffner [Mon, 5 Dec 2011 19:14:27 +0000 (14:14 -0500)]
User mode support for Linux ELF files with no section header

In user mode Linux, Qemu currently refuses to load ELF files that do not
contain section headers (ehdr->e_shentsize == 0). Since section headers are not
required in order to load an ELF file, simply removing the e_shentsize check in
elf_check_ehdr() allows ELF binaries with no section headers to be run properly
in user mode:

Signed-off-by: Craig Heffner <cheffner@tacnetsol.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user: Return correct errno for unsupported netlink socket
Ed Swierk [Tue, 6 May 2014 03:04:45 +0000 (20:04 -0700)]
linux-user: Return correct errno for unsupported netlink socket

This fixes "Cannot open audit interface - aborting." when the
EAFNOSUPPORT errno differs between the target and host
architectures (e.g. mips target and x86_64 host).

Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user: Don't overrun guest buffer in sched_getaffinity
Peter Maydell [Thu, 15 May 2014 13:40:23 +0000 (14:40 +0100)]
linux-user: Don't overrun guest buffer in sched_getaffinity

If the guest's "long" type is smaller than the host's, then
our sched_getaffinity wrapper needs to round the buffer size
up to a multiple of the host sizeof(long). This means that when
we copy the data back from the host buffer to the guest's
buffer there might be more than we can fit. Rather than
overflowing the guest's buffer, handle this case by returning
EINVAL or ignoring the unused extra space, as appropriate.

Note that only guests using the syscall interface directly might
run into this bug -- the glibc wrappers around it will always
use a buffer whose size is a multiple of 8 regardless of guest
architecture.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user/uname: Return correct uname string for x86_64
Peter Maydell [Sat, 10 May 2014 11:25:53 +0000 (12:25 +0100)]
linux-user/uname: Return correct uname string for x86_64

We were returning the incorrect uname string (with a hyphen, not
an underscore) for x86_64. Fix this by removing the x86_64 special
case, since the default "just use UNAME_MACHINE" behaviour suffices.
This leaves cpu_to_uname_machine() special cases for only those
architectures which need to vary the string based on runtime CPU
features.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user: fix gcc-4.9 compiler error on __{get,put]}_user
Riku Voipio [Tue, 22 Apr 2014 12:40:50 +0000 (15:40 +0300)]
linux-user: fix gcc-4.9 compiler error on __{get,put]}_user

gcc-4.9 finds unused operand:

linux-user/syscall.c: In function ‘host_to_target_stat64’:
linux-user/qemu.h:301:19: error: right-hand operand of comma expression
has no effect [-Werror=unused-value]
      ((hptr), (x)), 0)

Just removing the rh operand is no good, it will error in later:

linux-user/main.c: In function ‘arm_kernel_cmpxchg64_helper’:
linux-user/qemu.h:330:15: error: void value not ignored as it ought to be
         __ret = __put_user((x), __hptr);    \

Thus, remove setting __ret from __get_user and __put_user, as and
set the right hand operand to (void)0 to make it clear that these
return never nothing.

This commit depends on the signal.c cleanup, to ensure bisectable
version history.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Richard Henderson <rth@twiddle.net>
10 years agosignal/ppc/do_setcontext remove __get_user return check
Riku Voipio [Wed, 23 Apr 2014 11:05:09 +0000 (14:05 +0300)]
signal/ppc/do_setcontext remove __get_user return check

The last remaining check for return value of __get_user.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Graf <agraf@suse.de>
10 years agosignal/sparc64_set_context: remove __get_user checks
Riku Voipio [Wed, 23 Apr 2014 11:02:36 +0000 (14:02 +0300)]
signal/sparc64_set_context: remove __get_user checks

Remove checks of __get_user and the err variable
used to control flow with it.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/ppc/{save,restore}_user_regs remove __put/get error checks
Riku Voipio [Wed, 23 Apr 2014 10:53:45 +0000 (13:53 +0300)]
signal/ppc/{save,restore}_user_regs remove __put/get error checks

As __get_user and __put_user do not return errors, remove the
if checks from around them. This allows making the save/restore
functions void.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Graf <agraf@suse.de>
10 years agosignal/all/setup_frame remove __put_user checks
Riku Voipio [Wed, 23 Apr 2014 10:34:15 +0000 (13:34 +0300)]
signal/all/setup_frame remove __put_user checks

Remove "if(__put_user" checks and their related error paths
for all architecture's setup_frame, setup_rt_frame and similar.

Remove the unlock_user_struct when the only way to end up there is
from failed lock_user_struct.

Remove err variable if there are no users for it in the function
anymore.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all/do_sigreturn - remove __get_user checks
Riku Voipio [Wed, 23 Apr 2014 10:00:17 +0000 (13:00 +0300)]
signal/all/do_sigreturn - remove __get_user checks

Remove "if(__get_user" checks and their related error paths
for all architecture's do_sigreturn. Remove the unlock_user_struct
when the only way to end up there is from failed lock_user_struct.

v3: remove unneccesary sigsegv label as suggested by Peter

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all/do_sigaltstack remove __get_user value check
Riku Voipio [Wed, 23 Apr 2014 08:26:34 +0000 (11:26 +0300)]
signal/all/do_sigaltstack remove __get_user value check

Access is already checked in the lock_user_struct
call before.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/sparc/restore_fpu_state: remove
Riku Voipio [Wed, 23 Apr 2014 08:22:38 +0000 (11:22 +0300)]
signal/sparc/restore_fpu_state: remove

A function never called from anywhere, obviously half-complete.
Remove function and if someone wants to complete this, please
check the old version out of git history.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove return value from restore_sigcontext
Riku Voipio [Wed, 23 Apr 2014 08:19:48 +0000 (11:19 +0300)]
signal/all: remove return value from restore_sigcontext

make most implementations of restore_sigcontext void and
remove checking it's return value from functions calling
restore_sigcontext.

The exception is the X86 version of the function that is
too different from others to deal in this way, and arm
version, to keep possibility of erroring out from failed
valid_user_regs.

v3: keep arm valid_user_regs for filling in near future.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove return value from setup_sigcontext
Riku Voipio [Wed, 23 Apr 2014 08:01:00 +0000 (11:01 +0300)]
signal/all: remove return value from setup_sigcontext

Make all implementations of setup_sigcontext void and
remove checking it's return value from functions calling
setup_sigcontext.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove return value from copy_siginfo_to_user
Riku Voipio [Wed, 23 Apr 2014 07:46:13 +0000 (10:46 +0300)]
signal/all: remove return value from copy_siginfo_to_user

Since copy_siginfo_to_user always returns 0, make it void
and remove any checks for return value from calling functions.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/x86/setup_frame: __put_user cleanup
Riku Voipio [Wed, 23 Apr 2014 07:34:53 +0000 (10:34 +0300)]
signal/x86/setup_frame: __put_user cleanup

Remove the remaining check for __put_user return
value, and all the checks for err variable which
isn't set anywhere anymore.

No we can only end up in give_sigsegv due to failed
lock_user_struct - thus we remove the unlock_user_struct
to avoid unlocking a region never locked.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove __get/__put_user return value reading
Riku Voipio [Wed, 23 Apr 2014 07:26:05 +0000 (10:26 +0300)]
signal/all: remove __get/__put_user return value reading

Remove all the simple cases of reading the return value
of __get_user and __put_user.

We set err = 0 in sparc versions of do_sigreturn and
sparc64_set_context to avoid compile error, but else this patch is
just general removal of err |= __get_user ... idiom.

v2: remove err variable from target_rt_restore_ucontext

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging
Peter Maydell [Mon, 16 Jun 2014 17:26:21 +0000 (18:26 +0100)]
Merge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging

Patch queue for ppc - 2014-06-16

This pull request brings a lot of fun things. Among others we have

  - e500: u-boot firmware support
  - sPAPR: magic page enablement
  - sPAPR: add "compat" CPU option to support older guests
  - sPAPR: refactorings in preparation for VFIO
  - POWER8 live migration
  - mac99: expose bus frequency
  - little endian core dump, gdb and disas support
  - new ppc64le-linux-user target
  - DFP emulation
  - bug fixes

# gpg: Signature made Mon 16 Jun 2014 12:28:32 BST using RSA key ID 03FEDC60
# gpg: Can't check signature: public key not found

* remotes/agraf/tags/signed-ppc-for-upstream: (156 commits)
  spapr_pci: Advertise MSI quota
  PPC: KVM: Make pv hcall endian agnostic
  powerpc: use float64 for frsqrte
  spapr: Add kvm-type property
  spapr: Create SPAPRMachine struct
  linux-user: Tell guest about big host page sizes
  spapr_hcall: Add address-translation-mode-on-interrupt resource in H_SET_MODE
  spapr_hcall: Split h_set_mode()
  target-ppc: Enable DABRX SPR and limit it to <=POWER7
  target-ppc: Enable PPR and VRSAVE SPRs migration
  target-ppc: Add POWER8's Event Based Branch (EBB) control SPRs
  KVM: target-ppc: Enable TM state migration
  target-ppc: Add POWER8's TM SPRs
  target-ppc: Add POWER8's MMCR2/MMCRS SPRs
  target-ppc: Enable FSCR facility check for TAR
  target-ppc: Add POWER8's FSCR SPR
  target-ppc: Add POWER8's TIR SPR
  target-ppc: Refactor class init for POWER7/8
  target-ppc: Switch POWER7/8 classes to use correct PMU SPRs
  target-ppc: Make use of gen_spr_power5p_lpar() for POWER7/8
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agorules.mak: remove $(sort) from extract-libs
Paolo Bonzini [Mon, 16 Jun 2014 14:43:25 +0000 (16:43 +0200)]
rules.mak: remove $(sort) from extract-libs

Duplicate removal was added to extract-libs in order to avoid including
the same library multiple times into the linking command line; this could
potentially happen when using "foo.mo-libs" (which adds the library to
all components, causing it to appear N times if the module is composed
of N objects).  However, sorting and removing duplicates causes problems
with static linking, and also with space-separated linker options as
found in some Mac OS X packaging systems.  Furthermore, the "optimization"
is really a non-problem since we do not expect .mo modules to be composed
of many files.

Reported-by: Sean Bruno <sbruno@ignoranthack.me>
Tested-by: Sean Bruno <sbruno@ignoranthack.me>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1402929805-16836-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Mon, 16 Jun 2014 11:27:47 +0000 (12:27 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

Block pull request

# gpg: Signature made Mon 16 Jun 2014 12:22:22 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request: (39 commits)
  QemuOpts: cleanup tmp 'allocated' member from QemuOptsList
  cleanup QEMUOptionParameter
  vpc.c: replace QEMUOptionParameter with QemuOpts
  vmdk.c: replace QEMUOptionParameter with QemuOpts
  vhdx.c: replace QEMUOptionParameter with QemuOpts
  vdi.c: replace QEMUOptionParameter with QemuOpts
  ssh.c: replace QEMUOptionParameter with QemuOpts
  sheepdog.c: replace QEMUOptionParameter with QemuOpts
  rbd.c: replace QEMUOptionParameter with QemuOpts
  raw_bsd.c: replace QEMUOptionParameter with QemuOpts
  raw-win32.c: replace QEMUOptionParameter with QemuOpts
  raw-posix.c: replace QEMUOptionParameter with QemuOpts
  qed.c: replace QEMUOptionParameter with QemuOpts
  qcow2.c: replace QEMUOptionParameter with QemuOpts
  QemuOpts: export qemu_opt_find
  qcow.c: replace QEMUOptionParameter with QemuOpts
  nfs.c: replace QEMUOptionParameter with QemuOpts
  iscsi.c: replace QEMUOptionParameter with QemuOpts
  gluster.c: replace QEMUOptionParameter with QemuOpts
  cow.c: replace QEMUOptionParameter with QemuOpts
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agospapr_pci: Advertise MSI quota
Badari Pulavarty [Wed, 11 Jun 2014 08:49:33 +0000 (18:49 +1000)]
spapr_pci: Advertise MSI quota

Hotplug of multiple disks fails due to MSI vector quota check.
Number of MSI vectors default to 8 allowing only 4 devices.
This happens on RHEL6.5 guest. RHEL7 and SLES11 guests fallback
to INTX.

One way to workaround the issue is to increase total MSIs,
so that MSI quota check allows us to hotplug multiple disks.

This sets the quota to the maximum number of interupts XICS has
which is 1024 now (XICS_IRQS). This moves XICS_IRQS from spapr.c
to xics.h for wider visibility.

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
[aik: put XICS_IRQS=1024 instead of 64i, fixed endianness and size]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoPPC: KVM: Make pv hcall endian agnostic
Alexander Graf [Wed, 11 Jun 2014 10:19:03 +0000 (12:19 +0200)]
PPC: KVM: Make pv hcall endian agnostic

There were a few revisions of the Linux kernel that incorrectly swapped
the hcall instructions when they saw ePAPR compliant hypercalls.

We already have fixups for those in place when running with PR KVM, but
HV KVM and systems that don't implement hypercalls at all are still broken
because they fall back to the QEMU implementation of fallback hypercalls.

So let's make the fallback hypercall instruction path endian agnostic. This
only really works well for 64bit guests, but I don't think there are any 32bit
systems left that don't implement real pv hcall support, so we'll never get
into this code path.

Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agopowerpc: use float64 for frsqrte
Tristan Gingold [Tue, 3 Jun 2014 09:14:20 +0000 (11:14 +0200)]
powerpc: use float64 for frsqrte

Remove the code that reduce the result to float32 as the frsqrte
instruction is defined to return a double-precision estimate of
the reciprocal square root.

Although reducing the fractional part is harmless (as the estimation
must have at least 12 bits of precision according to the old PEM),
reducing the exponent range is not correct.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Add kvm-type property
Eduardo Habkost [Fri, 30 May 2014 21:24:32 +0000 (18:24 -0300)]
spapr: Add kvm-type property

The kvm-type machine option was left out when MachineState was
introduced, preventing the kvm-type option from being used. Add the
missing property to the sPAPR machine class, so it can be used.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Create SPAPRMachine struct
Eduardo Habkost [Fri, 30 May 2014 21:24:31 +0000 (18:24 -0300)]
spapr: Create SPAPRMachine struct

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agolinux-user: Tell guest about big host page sizes
Alexander Graf [Thu, 5 Jun 2014 09:39:43 +0000 (11:39 +0200)]
linux-user: Tell guest about big host page sizes

We tell the guest its page size via AUX vectors. The guest process then uses
this page size as information on which boundaries it can mmap() things.

However, if the host has a bigger page size granularity than the guest, it can
not fulfill these mmap() requests - which falls apart when MAP_FIXED is passed
to mmap.

So in that case, let the guest know that we're running on a bigger page size
granularity than the target would require.

This fixes running qemu-ppc (TARGET_PAGE_SIZE=4k) on a 64k page size ppc64 host
for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
10 years agospapr_hcall: Add address-translation-mode-on-interrupt resource in H_SET_MODE
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:51:05 +0000 (22:51 +1000)]
spapr_hcall: Add address-translation-mode-on-interrupt resource in H_SET_MODE

This adds handling of the RESOURCE_ADDR_TRANS_MODE resource from
the H_SET_MODE, for POWER8 (PowerISA 2.07) only.

This defines AIL flags for LPCR special register.

This changes @excp_prefix according to the mode, takes effect in TCG.

This turns support of a new capability PPC2_ISA207S flag for TCG.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr_hcall: Split h_set_mode()
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:51:04 +0000 (22:51 +1000)]
spapr_hcall: Split h_set_mode()

This moves H_SET_MODE_RESOURCE_LE handler to a separate function
as there are other "resources" coming and this is going to become ugly.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Enable DABRX SPR and limit it to <=POWER7
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:51:03 +0000 (22:51 +1000)]
target-ppc: Enable DABRX SPR and limit it to <=POWER7

This adds DABRX SPR.

As DABR(X) are present in POWER CPUs till POWER7 only and POWER8 does not
have them (as it implements more powerful facility instead), this limits
DABR/DABRX registration by POWER7 (inclusive).

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Enable PPR and VRSAVE SPRs migration
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:51:02 +0000 (22:51 +1000)]
target-ppc: Enable PPR and VRSAVE SPRs migration

This hooks SPR with their "KVM set_one_reg" counterparts which enables
their migration.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add POWER8's Event Based Branch (EBB) control SPRs
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:51:01 +0000 (22:51 +1000)]
target-ppc: Add POWER8's Event Based Branch (EBB) control SPRs

POWER8 supports Event-Based Branch Facility (EBB). It is controlled via
set of SPRs access to which should generate an "Facility Unavailable"
interrupt if the facilities are not enabled in FSCR for problem state.

This adds EBB SPRs.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoKVM: target-ppc: Enable TM state migration
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:51:00 +0000 (22:51 +1000)]
KVM: target-ppc: Enable TM state migration

This adds migration support for registers saved before Transactional
Memory (TM) transaction started.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add POWER8's TM SPRs
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:59 +0000 (22:50 +1000)]
target-ppc: Add POWER8's TM SPRs

This adds TM (Transactional Memory) SPRs.

This adds generic spr_read_prev_upper32()/spr_write_prev_upper32() to
handle upper half SPRs such as TEXASRU which is upper half of TEXASR.
Since this is not the only register like that and their numbers go
consequently, it makes sense to generalize the helpers.

This adds a gen_msr_facility_check() helper which purpose is to generate
the Facility Unavailable exception if the facility is disabled.
It is a copy of gen_fscr_facility_check() but it checks for enabled
facility in MSR rather than FSCR/HFSCR. It still sets the interrupt cause
in FSCR/HFSCR (whichever is passed to the helper).

This adds spr_read_tm/spr_write_tm/spr_read_tm_upper32/spr_write_tm_upper32
which are used for TM SPRs.

This adds TM-relates MSR bits definitions. This enables TM in POWER8 CPU class'
msr_mask.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add POWER8's MMCR2/MMCRS SPRs
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:58 +0000 (22:50 +1000)]
target-ppc: Add POWER8's MMCR2/MMCRS SPRs

This adds POWER8 specific PMU MMCR2/MMCRS SPRs.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Enable FSCR facility check for TAR
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:57 +0000 (22:50 +1000)]
target-ppc: Enable FSCR facility check for TAR

This makes user-privileged read/write fail if TAR facility is not enabled
in FSCR.

Since this is the very first check for enabled in FSCR facility,
this also adds gen_fscr_facility_check() for using in spr_write_tar()/
spr_read_tar().

This enables TAR in FSCR for user mode unconditionally.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add POWER8's FSCR SPR
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:56 +0000 (22:50 +1000)]
target-ppc: Add POWER8's FSCR SPR

This adds an FSCR (Facility Status and Control Register) SPR. This defines
names for FSCR bits.

This defines new exception type - POWERPC_EXCP_FU - "facility unavailable" (FU).
This registers an interrupt vector for it at 0xF60 as PowerISA defines.

This adds a TCG helper_fscr_facility_check() helper to raise an exception
if the facility is not enabled. It updates the interrupt cause field
in FSCR. This adds a TCG translation block generation code. The helper
may be used for HFSCR too as it has the same format.

The helper raising FU exceptions is not used by this patch but will be
in the next ones.

This adds gen_update_current_nip() to update NIP in DisasContext.
This helper is not used now and will be called before checking for
a condition for throwing an FU exception.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add POWER8's TIR SPR
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:55 +0000 (22:50 +1000)]
target-ppc: Add POWER8's TIR SPR

This adds TIR (Thread Identification Register) SPR first defined for server
CPUs in PowerISA 2.07.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Refactor class init for POWER7/8
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:54 +0000 (22:50 +1000)]
target-ppc: Refactor class init for POWER7/8

This extends init_proc_book3s_64 to support POWER7 and POWER8.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Switch POWER7/8 classes to use correct PMU SPRs
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:53 +0000 (22:50 +1000)]
target-ppc: Switch POWER7/8 classes to use correct PMU SPRs

This replaces gen_spr_7xx() call (which registers 32bit SPRs) with
gen_spr_book3s_pmu() call.

This removes SPR_7XX_PMC5/6 as they are for 32bit and gen_spr_book3s_pmu()
already registers correct PMC5/6 SPRs.

This removes explicit MMCRA registration as gen_spr_book3s_pmu() does it
anyway.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Make use of gen_spr_power5p_lpar() for POWER7/8
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:52 +0000 (22:50 +1000)]
target-ppc: Make use of gen_spr_power5p_lpar() for POWER7/8

This makes use of generic gen_spr_power5p_lpar() which registers LPCR SPR.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Make use of gen_spr_book3s_altivec() for POWER7/8
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:51 +0000 (22:50 +1000)]
target-ppc: Make use of gen_spr_book3s_altivec() for POWER7/8

This replaces VRSAVE registration and vscr_init() call with
gen_spr_book3s_altivec() which is generic and does the same thing if
insns_flags has PPC_ALTIVEC bit set (which POWER7/8 have set).

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Move POWER7/8 CFAR/DSCR/CTRL/PPR/PCR SPR registration to helpers
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:50 +0000 (22:50 +1000)]
target-ppc: Move POWER7/8 CFAR/DSCR/CTRL/PPR/PCR SPR registration to helpers

This moves SCFAR/DSCR/CTRL/PPR/PCR PRs to helpers. Later these helpers
will be called from generalized init_proc_book3s_64().

This switches init_proc_POWER7() to use generalized gen_spr_book3s_common()
which registers CRTL SPR under slightly different names. No change in
behaviour or non-debug output is expected.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Move POWER8 TCE Address control (TAR) to a helper
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:49 +0000 (22:50 +1000)]
target-ppc: Move POWER8 TCE Address control (TAR) to a helper

This moves TAR SPR to a helper. Later this helper will be
called from generalized init_proc_book3s_64().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Move POWER7/8 PIR/PURR/SPURR SPR registration to helpers
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:48 +0000 (22:50 +1000)]
target-ppc: Move POWER7/8 PIR/PURR/SPURR SPR registration to helpers

This moves PIR/PURR/SPURR SPRs to helpers. Later these helpers will be
called from generalized init_proc_book3s_64().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Enable PMU SPRs migration
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:47 +0000 (22:50 +1000)]
target-ppc: Enable PMU SPRs migration

This enabled PMU SPRs migration by hooking hypv privileged versions with
"KVM one reg" IDs.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Remove check_pow_970FX
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:46 +0000 (22:50 +1000)]
target-ppc: Remove check_pow_970FX

After merging 970s into one class, check_pow_970() is used for all of them.
Since POWER5+ is no different in the matter of supported power modes,
let's use the same check_pow() callback for POWER5+ too,

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Introduce and reuse generalized init_proc_book3s_64()
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:45 +0000 (22:50 +1000)]
target-ppc: Introduce and reuse generalized init_proc_book3s_64()

At the moment every POWER CPU family has its own init_proc_POWERX function.
E500 already has common init function so we try to do the same thing.

This introduces BOOK3S_CPU_TYPE enum with 2 values - 970 and POWER5+.

This introduces generalized init_proc_book3s_64() which accepts a CPU type
as a parameter.

This uses new init function for 970 and POWER5+ CPU classes.

970 and POWER5+ use the same CPU class initialization except 3 things:
1. logical partitioning is controlled by LPCR (POWER5+) and HID4 (970)
SPRs;
2. 970 does not have EAR (External Access Register) SPR and PowerISA 2.03
defines one so keep it only for POWER5+;
3. POWER5+ does not have ALTIVEC so insns_flags does not have PPC_ALTIVEC
flag set and gen_spr_book3s_altivec() won't init ALTIVEC for POWER5+.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add HID4 SPR for PPC970
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:44 +0000 (22:50 +1000)]
target-ppc: Add HID4 SPR for PPC970

Previously LPCR was registered for the 970 class which was wrong as
it does not have LPCR. Instead, HID4 is used which this patch registers.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add PMC7/8 to 970 class
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:43 +0000 (22:50 +1000)]
target-ppc: Add PMC7/8 to 970 class

Compared to PowerISA-compliant CPUs, 970 family has most of them plus
PMC7/8 which are only present on 970 but not on POWER5 and later CPUs.

Since we are changing SPRs for Book3s/970 families, let's add them too.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add PMC5/6, SDAR and MMCRA to 970 family
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:42 +0000 (22:50 +1000)]
target-ppc: Add PMC5/6, SDAR and MMCRA to 970 family

MMCR0, MMCR1, MMCRA, PMC1..6, SIAR, SDAR are defined for 970 and PowerISA
CPUs. Since we are building common infrastructure for SPRs intialization
to share it between 970 and POWER5+/7/..., let's add missing SPRs to
the 970 family. Later rework of CPU class initialization will use those
for all PowerISA CPUs.

This adds new SPRs and enables writing to Uxxxx SPRs from supermode.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add "POWER" prefix to MMCRA PMU registers
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:41 +0000 (22:50 +1000)]
target-ppc: Add "POWER" prefix to MMCRA PMU registers

Since we started adding "POWER" prefix to 64bit PMU SPRs, let's finish
the transition and fix MMCRA and define a supermode version of it.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Copy and split gen_spr_7xx() for 970
Alexey Kardashevskiy [Wed, 4 Jun 2014 12:50:40 +0000 (22:50 +1000)]
target-ppc: Copy and split gen_spr_7xx() for 970

This stops using 7xx common SPRs init function and adds separate set
of helpers for 970.

This does not copy ICTC SPR as neither 970 manual nor PowerISA mention it.

This defines 970/book3s PMU SPRs constants as they differs from the ones
used for 7XX.

This creates 2 helpers for PMU SPRs, one for supermode privileged SPRs and
one for user privileged SPRs as "sup" versions can be shared across
the family while "user" versions will behave different starting POWER8
(which will be addressed later).

This allows writing to Uxxxx SPRs from supermode. spr_write_ureg() is
implemented for this as a copy of already existing spr_read_ureg().

This allows writing to supervisor's SIAR - it used to be disabled
when gen_spr_7xx() was used.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>