sdk/emulator/qemu.git
10 years agobuild: Fix installation of target-dependent files
Lluís Vilanova [Mon, 20 Jan 2014 11:21:54 +0000 (12:21 +0100)]
build: Fix installation of target-dependent files

Pass all the relevant sub-directory make variables.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20140120112153.5685.30949.stgit@fimbulvetr.bsc.es

10 years agoxenfb: Fix graphic_console_init() build failure
Andreas Färber [Fri, 7 Mar 2014 21:42:08 +0000 (22:42 +0100)]
xenfb: Fix graphic_console_init() build failure

In commit 5643706a095044d75df1c0588aac553a595b972b (console: add head
to index to qemu consoles.) graphic_console_init() was extended to take
an additional argument, but xenfb was not updated accordingly. Fix it.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Don Slutz <dslutz@verizon.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1394228528-31625-1-git-send-email-afaerber@suse.de

10 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-input-4' into staging
Peter Maydell [Fri, 7 Mar 2014 18:29:32 +0000 (18:29 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-4' into staging

Input handling rewrite.
SDL2 support.

# gpg: Signature made Wed 05 Mar 2014 11:16:08 GMT using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-input-4: (38 commits)
  ui/sdl2 : initial port to SDL 2.0 (v2.0)
  console: add QemuUIInfo
  console: add head to index to qemu consoles.
  input: remove index_from_keycode (no users)
  input: move do_mouse_set to new core
  input: move qmp_query_mice to new core
  input: add input_mouse_mode tracepoint
  input: move mouse mode notifier to new core
  input-legacy: remove kbd_mouse_event
  input-legacy: remove kbd_mouse_is_absolute
  input-legacy: remove kbd_mouse_has_absolute
  input-legacy: remove kbd_put_keycode
  input: trace events
  input: mouse: switch cocoa ui to new core
  input: keyboard: switch cocoa ui to new core
  input: mouse: switch monitor to new core
  input: mouse: switch spice ui to new core
  input: mouse: switch vnc ui to new core
  input: mouse: switch sdl ui to new core
  input: mouse: switch gtk ui to new core
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging
Peter Maydell [Fri, 7 Mar 2014 16:36:37 +0000 (16:36 +0000)]
Merge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging

Patch queue for ppc - 2014-03-05

This pull request includes:

  - VSX emulation support
  - book3s pr/hv selection
  - some bug fixes
  - qdev stable numbering
  - eTSEC emulation

# gpg: Signature made Wed 05 Mar 2014 02:14:19 GMT using RSA key ID 03FEDC60
# gpg: Can't check signature: public key not found

* remotes/agraf/tags/signed-ppc-for-upstream: (130 commits)
  target-ppc: spapr: e500: fix to use cpu_dt_id
  target-ppc: add PowerPCCPU::cpu_dt_id
  target-ppc: Introduce hypervisor call H_GET_TCE
  target-ppc: Update ppc_hash64_store_hpte to support updating in-kernel htab
  target-ppc: Change the hpte store API
  target-ppc: Fix page table lookup with kvm enabled
  target-ppc: Fix htab_mask calculation
  target-ppc: Use Additional Temporary in stqcx Case
  target-ppc: Fix Compiler Warnings Due to 64-Bit Constants Declared as UL
  PPC: sPAPR: Only use getpagesize() when we run with kvm
  target-ppc/translate.c: Use ULL suffix for 64 bit constants
  spapr-vlan: flush queue whenever can_receive can go from false to true
  target-ppc: Altivec 2.07: Vector Permute and Exclusive OR
  target-ppc: Altivec 2.07: Vector SHA Sigma Instructions
  target-ppc: Altivec 2.07: AES Instructions
  target-ppc: Altivec 2.07: Binary Coded Decimal Instructions
  target-ppc: Altivec 2.07: Vector Polynomial Multiply Sum
  target-ppc: Altivec 2.07: Vector Gather Bits by Bytes
  target-ppc: Altivec 2.07: Doubleword Compares
  target-ppc: Altivec 2.07: vbpermq Instruction
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/cohuck/tags/virtio-ccw-20140305' into staging
Peter Maydell [Fri, 7 Mar 2014 15:58:27 +0000 (15:58 +0000)]
Merge remote-tracking branch 'remotes/cohuck/tags/virtio-ccw-20140305' into staging

One patch introducing support for adapter interrupts in virtio-ccw.

This improves performance for those guests that issue the new
CCW_CMD_SET_IND_ADAPTER channel command.

# gpg: Signature made Wed 05 Mar 2014 08:48:18 GMT using RSA key ID C6F02FAF
# gpg: Can't check signature: public key not found

* remotes/cohuck/tags/virtio-ccw-20140305:
  s390x/virtio-ccw: Adapter interrupt support.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoconfigure: Always build with -fno-common
Peter Maydell [Wed, 26 Feb 2014 21:53:30 +0000 (21:53 +0000)]
configure: Always build with -fno-common

MacOSX doesn't pull .o files from .a archives if the symbol that it
requires is one which the .o file defines as a common symbol.
(Common symbols are those declared without "extern"; the linker
will merge together common symbols with the same name, so
redeclaring the same variable in two compilation units results in
them referring to the same symbol rather than a compilation error).

This MacOSX difference from traditional linker behaviour means that
"make check" produces link errors:

Undefined symbols for architecture x86_64:
  "_cur_mon", referenced from:
      _error_vprintf in libqemuutil.a(qemu-error.o)
      _error_printf in libqemuutil.a(qemu-error.o)
      _error_printf_unless_qmp in libqemuutil.a(qemu-error.o)
      _error_print_loc in libqemuutil.a(qemu-error.o)
      _error_report in libqemuutil.a(qemu-error.o)
ld: symbol(s) not found for architecture x86_64

in this case because "cur_mon" is a common symbol in
libqemustub.a(mon-set-error.o).

In QEMU we don't make any use at all of the common symbol
functionality, so we can avoid this problem entirely simply
by compiling with -fno-common. Enable this option for all
builds, not just MacOSX, so that if we ever inadvertently
introduce multiple definitions of some variable that will
be immediately spotted as a build error rather than only
breaking the MacOSX build.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1393451610-24617-1-git-send-email-peter.maydell@linaro.org

10 years agoconfigure: Make C++ test work with --enable-werror
Peter Maydell [Tue, 25 Feb 2014 18:27:49 +0000 (18:27 +0000)]
configure: Make C++ test work with --enable-werror

gcc's C++ compiler complains about being passed some -W options
which make sense for C but not for C++. This means we mustn't try
a C++ compile with QEMU_CFLAGS, but only with a filtered version
that removes the offending options. This filtering was already being
done for uses of C++ in the build itself, but was omitted for the
"does C++ work?" configure test. This only showed up when doing
builds which explicitly enabled -Werror with --enable-werror,
because the "do the compilers work" tests were mistakenly placed
above the "default werror based on whether compiling from git" code.
Another error in this category is that clang warns if you ask it to
compile C++ code from a file named "foo.c". Further, because we
were running do_cc in a subshell in the condition part of an "if",
the error_exit inside do_compiler wouldn't terminate configure and
we would plunge on regardless. Fix this complex of errors:

1. Move the default-werror code up so that there are no invocations
of compile_object and friends between it and the point where we
set $werror explicitly based on the --enable-werror command line
option.

2. Provide a mechanism for filtering QEMU_CFLAGS to create
QEMU_CXXFLAGS, and use it for the test we run here.

3. Provide a do_cxx function to run a test with the C++ compiler
rather than doing cute tricks with subshells and do_cc.

4. Use a new temporary file TMPCXX for the C++ program fragment.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1393352869-22257-1-git-send-email-peter.maydell@linaro.org
Tested-by: Andreas Färber <afaerber@suse.de>
10 years agoui/sdl2 : initial port to SDL 2.0 (v2.0)
Dave Airlie [Tue, 10 Dec 2013 04:05:51 +0000 (14:05 +1000)]
ui/sdl2 : initial port to SDL 2.0 (v2.0)

I've ported the SDL1.2 code over, and rewritten it to use the SDL2 interface.

The biggest changes were in the input handling, where SDL2 has done a major
overhaul, and I've had to include a generated translation file to get from
SDL2 codes back to qemu compatible ones. I'm still not sure how the keyboard
layout code works in qemu, so there may be further work if someone can point
me a test case that works with SDL1.2 and doesn't with SDL2.

Some SDL env vars we used to set are no longer used by SDL2,
Windows, OSX support is untested,

I don't think we can link to SDL1.2 and SDL2 at the same time, so I felt
using --with-sdlabi=2.0 to select the new code should be fine, like how
gtk does it.

v1.1: fix keys in text console
v1.2: fix shutdown, cleanups a bit of code, support ARGB cursor

v2.0: merge the SDL multihead patch into this, g_new the number of consoles
needed, wrap DCL inside per-console structure.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Fixes & improvements by kraxel:
 * baum build fix
 * remove text console logic
 * adapt to new input core
 * codestyle fixups

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoconsole: add QemuUIInfo
Gerd Hoffmann [Fri, 24 Jan 2014 16:38:20 +0000 (17:38 +0100)]
console: add QemuUIInfo

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoconsole: add head to index to qemu consoles.
Gerd Hoffmann [Fri, 24 Jan 2014 14:35:21 +0000 (15:35 +0100)]
console: add head to index to qemu consoles.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: remove index_from_keycode (no users)
Gerd Hoffmann [Tue, 10 Dec 2013 16:30:15 +0000 (17:30 +0100)]
input: remove index_from_keycode (no users)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: move do_mouse_set to new core
Gerd Hoffmann [Tue, 10 Dec 2013 16:16:03 +0000 (17:16 +0100)]
input: move do_mouse_set to new core

This removes the last user of the lecagy input mouse handler list,
so we can remove more legacy bits with this.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: move qmp_query_mice to new core
Gerd Hoffmann [Tue, 10 Dec 2013 16:09:36 +0000 (17:09 +0100)]
input: move qmp_query_mice to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: add input_mouse_mode tracepoint
Gerd Hoffmann [Thu, 5 Dec 2013 10:24:14 +0000 (11:24 +0100)]
input: add input_mouse_mode tracepoint

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: move mouse mode notifier to new core
Gerd Hoffmann [Thu, 5 Dec 2013 10:23:42 +0000 (11:23 +0100)]
input: move mouse mode notifier to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput-legacy: remove kbd_mouse_event
Gerd Hoffmann [Thu, 5 Dec 2013 10:21:21 +0000 (11:21 +0100)]
input-legacy: remove kbd_mouse_event

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput-legacy: remove kbd_mouse_is_absolute
Gerd Hoffmann [Thu, 5 Dec 2013 10:20:39 +0000 (11:20 +0100)]
input-legacy: remove kbd_mouse_is_absolute

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput-legacy: remove kbd_mouse_has_absolute
Gerd Hoffmann [Thu, 5 Dec 2013 07:19:02 +0000 (08:19 +0100)]
input-legacy: remove kbd_mouse_has_absolute

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput-legacy: remove kbd_put_keycode
Gerd Hoffmann [Thu, 5 Dec 2013 07:12:19 +0000 (08:12 +0100)]
input-legacy: remove kbd_put_keycode

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: trace events
Gerd Hoffmann [Wed, 4 Dec 2013 14:20:05 +0000 (15:20 +0100)]
input: trace events

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch cocoa ui to new core
Gerd Hoffmann [Wed, 4 Dec 2013 13:08:04 +0000 (14:08 +0100)]
input: mouse: switch cocoa ui to new core

Build fixes by Peter Maydell.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch cocoa ui to new core
Gerd Hoffmann [Wed, 4 Dec 2013 11:53:44 +0000 (12:53 +0100)]
input: keyboard: switch cocoa ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch monitor to new core
Gerd Hoffmann [Wed, 4 Dec 2013 14:02:28 +0000 (15:02 +0100)]
input: mouse: switch monitor to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch spice ui to new core
Gerd Hoffmann [Wed, 4 Dec 2013 11:46:34 +0000 (12:46 +0100)]
input: mouse: switch spice ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch vnc ui to new core
Gerd Hoffmann [Mon, 2 Dec 2013 14:17:45 +0000 (15:17 +0100)]
input: mouse: switch vnc ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch sdl ui to new core
Gerd Hoffmann [Thu, 28 Nov 2013 11:27:40 +0000 (12:27 +0100)]
input: mouse: switch sdl ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch gtk ui to new core
Gerd Hoffmann [Thu, 28 Nov 2013 11:06:04 +0000 (12:06 +0100)]
input: mouse: switch gtk ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: switch legacy handlers to new core
Gerd Hoffmann [Wed, 27 Nov 2013 16:41:40 +0000 (17:41 +0100)]
input: mouse: switch legacy handlers to new core

legacy mouse event handlers are registered in the new core,
so they receive events submitted to the new input core.

legacy kbd_mouse_event() continues to use the old code paths.
So new-core event handlers wouldn't see events submitted via
kbd_mouse_event.

This leads to the constrain that we we must transition all
kbd_mouse_event() users first to keep things working.  But
that is easier to handle than translating legacy mouse events
into new-core mouse events ;)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: add qemu_input_is_absolute()
Gerd Hoffmann [Thu, 28 Nov 2013 10:31:09 +0000 (11:31 +0100)]
input: mouse: add qemu_input_is_absolute()

Same as kbd_mouse_is_absolute(), but using new input core.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: add graphic_rotate support
Gerd Hoffmann [Thu, 28 Nov 2013 10:29:33 +0000 (11:29 +0100)]
input: mouse: add graphic_rotate support

Transform absolute mouse events according to graphic_rotate.

Legacy input code does it for both absolute and relative events,
but the logic is broken for relative coordinates, so this is
most likely not used anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: mouse: add helpers functions to core
Gerd Hoffmann [Wed, 27 Nov 2013 17:24:29 +0000 (18:24 +0100)]
input: mouse: add helpers functions to core

Likewise a bunch of helper functions to manage mouse button
and movement events, again to make life easier for the ui code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch curses ui to new core
Gerd Hoffmann [Wed, 4 Dec 2013 12:40:20 +0000 (13:40 +0100)]
input: keyboard: switch curses ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch spice ui to new core
Gerd Hoffmann [Wed, 4 Dec 2013 11:23:54 +0000 (12:23 +0100)]
input: keyboard: switch spice ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch vnc ui to new core
Gerd Hoffmann [Mon, 2 Dec 2013 13:27:18 +0000 (14:27 +0100)]
input: keyboard: switch vnc ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch sdl ui to new core
Gerd Hoffmann [Thu, 28 Nov 2013 11:17:35 +0000 (12:17 +0100)]
input: keyboard: switch sdl ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch gtk ui to new core
Gerd Hoffmann [Thu, 28 Nov 2013 10:40:27 +0000 (11:40 +0100)]
input: keyboard: switch gtk ui to new core

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch qmp_send_key() to new core.
Gerd Hoffmann [Wed, 27 Nov 2013 11:11:13 +0000 (12:11 +0100)]
input: keyboard: switch qmp_send_key() to new core.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: switch legacy handlers to new core
Gerd Hoffmann [Wed, 27 Nov 2013 10:59:25 +0000 (11:59 +0100)]
input: keyboard: switch legacy handlers to new core

legacy kbd event handlers are registered in the new core,
so they receive events from the new input core code.
keycode -> scancode translation needed here.

legacy kbd_put_keycode() sends events to the new core.
scancode -> keycode translation needed here.

So with this patch the new input core is fully functional
for keyboard events.  New + legacy interfaces can be mixed
in any way.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: keyboard: add helper functions to core
Gerd Hoffmann [Wed, 27 Nov 2013 10:38:47 +0000 (11:38 +0100)]
input: keyboard: add helper functions to core

A bunch of helper functions to manage keyboard events,
to make life simpler for the ui code when submitting
keyboard events.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: add core bits of the new input layer
Gerd Hoffmann [Wed, 27 Nov 2013 09:35:26 +0000 (10:35 +0100)]
input: add core bits of the new input layer

Register and unregister handlers.
Event dispatcher code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoinput: qapi: add pause key
Gerd Hoffmann [Mon, 16 Dec 2013 09:34:53 +0000 (10:34 +0100)]
input: qapi: add pause key

It's missing.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoinput: qapi: add unmapped key
Gerd Hoffmann [Fri, 13 Dec 2013 11:10:14 +0000 (12:10 +0100)]
input: qapi: add unmapped key

Simplifies building something -> QkeyCode mapping tables.
Uninitialized entries can easily identified then.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoinput: qapi: define event types
Gerd Hoffmann [Wed, 27 Nov 2013 08:08:40 +0000 (09:08 +0100)]
input: qapi: define event types

Define input event types, using qapi.  So we get nicely autogenerated
types for our input events.  And when it comes to qmp support some day
things will be a lot easier.

Types are modeled after the linux input layer.  There are separate
event types for each value.  There is a sync to indicate the end
of a event group.

Mouse events are split into motion events (one for each axis) and
button events, which are grouped by sync.

Keyboard events are using the existing KeyValue type.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoinput: rename file to legacy
Gerd Hoffmann [Wed, 27 Nov 2013 08:29:27 +0000 (09:29 +0100)]
input: rename file to legacy

Rename ui/input.c to ui/input-legacy.c.
We are going to replace it step by step.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoconsole: export QemuConsole index,width,height
Gerd Hoffmann [Thu, 28 Nov 2013 08:58:18 +0000 (09:58 +0100)]
console: export QemuConsole index,width,height

Add functions to query QemuConsole properties.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agos390x/virtio-ccw: Adapter interrupt support.
Cornelia Huck [Wed, 6 Feb 2013 09:31:37 +0000 (10:31 +0100)]
s390x/virtio-ccw: Adapter interrupt support.

Handle the new CCW_CMD_SET_IND_ADAPTER command enabling adapter interrupts
on guest request. When active, host->guest notifications will be handled
via global_indicator -> queue indicators instead of queue indicators +
subchannel I/O interrupt. Indicators for virtqueues may be present at an
offset.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
10 years agotarget-ppc: spapr: e500: fix to use cpu_dt_id
Alexey Kardashevskiy [Sat, 1 Feb 2014 14:45:52 +0000 (01:45 +1100)]
target-ppc: spapr: e500: fix to use cpu_dt_id

This makes use of @cpu_dt_id and related API in:
1. emulated XICS hypercall handlers as they receive fixed CPU indexes;
2. XICS-KVM to enable in-kernel XICS on right CPU;
3. device-tree renderer.

This removes @cpu_index fixup as @cpu_dt_id is used instead so QEMU monitor
can accept command-line CPU indexes again.

This changes kvm_arch_vcpu_id() to use ppc_get_vcpu_dt_id() as at the moment
KVM CPU id and device tree ID are calculated using the same algorithm.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: add PowerPCCPU::cpu_dt_id
Alexey Kardashevskiy [Sat, 1 Feb 2014 14:45:51 +0000 (01:45 +1100)]
target-ppc: add PowerPCCPU::cpu_dt_id

Normally CPUState::cpu_index is used to pick the right CPU for various
operations. However default consecutive numbering does not always work
for POWERPC.

These indexes are reflected in /proc/device-tree/cpus/PowerPC,POWER7@XX
and used to call KVM VCPU's ioctls. In order to achieve this,
kvmppc_fixup_cpu() was introduced. Roughly speaking, it multiplies
cpu_index by the number of threads per core.

This approach has disadvantages such as:
1. NUMA configuration stays broken after the fixup;
2. CPU-targeted commands from the QEMU Monitor do not work properly as
CPU indexes have been fixed and there is no clear way for the user to
know what the new CPU indexes are.

This introduces a @cpu_dt_id field in the CPUPPCState struct which
is initialized from @cpu_index by default and can be fixed later
to meet the device tree requirements.

This adds an API to handle @cpu_dt_id.

This removes kvmppc_fixup_cpu() as it is not more needed, @cpu_dt_id
is calculated in ppc_cpu_realize().

This will be used later in machine code.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Introduce hypervisor call H_GET_TCE
Laurent Dufour [Fri, 21 Feb 2014 09:29:06 +0000 (10:29 +0100)]
target-ppc: Introduce hypervisor call H_GET_TCE

This patch introduces the hypervisor call H_GET_TCE which is basically the
reverse of H_PUT_TCE, as defined in the Power Architecture Platform
Requirements (PAPR).

The hcall H_GET_TCE is required by the kdump kernel which is calling it to
retrieve the TCE set up by the panicing kernel.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Update ppc_hash64_store_hpte to support updating in-kernel htab
Aneesh Kumar K.V [Thu, 20 Feb 2014 17:52:38 +0000 (18:52 +0100)]
target-ppc: Update ppc_hash64_store_hpte to support updating in-kernel htab

This support updating htab managed by the hypervisor. Currently we don't have
any user for this feature. This actually bring the store_hpte interface
in-line with the load_hpte one. We may want to use this when we want to
emulate henter hcall in qemu for HV kvm.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
[ folded fix for the "warn_unused_result" build break in
  kvmppc_hash64_write_pte(), Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Change the hpte store API
Aneesh Kumar K.V [Thu, 20 Feb 2014 17:52:31 +0000 (18:52 +0100)]
target-ppc: Change the hpte store API

For updating in kernel htab we need to provide both pte0 and pte1, hence update
the interface to take pte0 and pte1 together

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
[ ldq_phys() API change, Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Fix page table lookup with kvm enabled
Aneesh Kumar K.V [Thu, 20 Feb 2014 17:52:24 +0000 (18:52 +0100)]
target-ppc: Fix page table lookup with kvm enabled

With kvm enabled, we store the hash page table information in the hypervisor.
Use ioctl to read the htab contents. Without this we get the below error when
trying to read the guest address

 (gdb) x/10 do_fork
 0xc000000000098660 <do_fork>:   Cannot access memory at address 0xc000000000098660
 (gdb)

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
[ fixes for 32 bit build (casts!), ldq_phys() API change,
  Greg Kurz <gkurz@linux.vnet.ibm.com ]
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Fix htab_mask calculation
Aneesh Kumar K.V [Thu, 20 Feb 2014 17:52:17 +0000 (18:52 +0100)]
target-ppc: Fix htab_mask calculation

Correctly update the htab_mask using the return value of
KVM_PPC_ALLOCATE_HTAB ioctl. Also we don't update sdr1
on GET_SREGS for HV. We check for external htab and if
found true, we don't need to update sdr1

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
[ fixed pte group offset computation in ppc_hash64_htab_lookup() that
  caused TCG to fail, Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Use Additional Temporary in stqcx Case
Tom Musta [Mon, 24 Feb 2014 14:16:16 +0000 (08:16 -0600)]
target-ppc: Use Additional Temporary in stqcx Case

Per Alex Graf's suggestion, the recently added case to gen_conditional_store
for stqcx should use an additional temporary when accessing the second
doubleword.  This avoids the mutation of the EA argument to the function,
which is counter intuitive.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Fix Compiler Warnings Due to 64-Bit Constants Declared as UL
Tom Musta [Mon, 24 Feb 2014 14:12:13 +0000 (08:12 -0600)]
target-ppc: Fix Compiler Warnings Due to 64-Bit Constants Declared as UL

This patch fixes 64 bit constants that were erroneously declared as "ul" instead of
"ull".  The preferred form "ULL" is used.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoPPC: sPAPR: Only use getpagesize() when we run with kvm
Alexander Graf [Fri, 21 Feb 2014 09:38:51 +0000 (10:38 +0100)]
PPC: sPAPR: Only use getpagesize() when we run with kvm

We currently size the msi window trap page according to the host's page
size so that we poke a working hole into a memory slot in case we overlap.

However, this is only ever necessary with KVM active. Without KVM, we should
rather try to be host platform agnostic and use a constant size: 4k.

This fixes a build breakage on win32 hosts.

Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc/translate.c: Use ULL suffix for 64 bit constants
Peter Maydell [Thu, 20 Feb 2014 19:47:27 +0000 (19:47 +0000)]
target-ppc/translate.c: Use ULL suffix for 64 bit constants

64 bit constants need the "ULL" suffix, not just "UL", because
on 32 bit platforms 'long' is not large enough and this will
cause a compiler warning.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr-vlan: flush queue whenever can_receive can go from false to true
Alexey Kardashevskiy [Fri, 14 Feb 2014 01:27:04 +0000 (12:27 +1100)]
spapr-vlan: flush queue whenever can_receive can go from false to true

When the guests adds buffers to receive queue, the network device
should flush its queue of pending packets. This is done with
qemu_flush_queued_packets.

This adds a call to qemu_flush_queued_packets() which wakes up the main
loop and let QEMU update the network device status which now is "can
receive". The patch basically does the same thing as e8b4c68 does.

Suggested-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Permute and Exclusive OR
Tom Musta [Wed, 12 Feb 2014 21:23:19 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Permute and Exclusive OR

This patch adds the Vector Permuate and Exclusive OR (vpermxor)
instruction introduced in Power ISA Version 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector SHA Sigma Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:18 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector SHA Sigma Instructions

This patch adds the Vector SHA Sigma instructions introduced in Power
ISA Version 2.07:

  - Vector SHA-512 Sigma Doubleword (vshasigmad)
  - Vector SHA-256 Sigma Word (vshasigmaw)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: AES Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:17 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: AES Instructions

This patch adds the Vector AES instructions introduced in Power ISA
Version 2.07:

   - Vector AES Cipher (vcipher)
   - Vector AES Cipher Last (vcipherlast)
   - Vector AES Inverse Cipher (vncipher)
   - Vector AES Inverse Cipher Last (vncipherlast)
   - Vector AES SubBytes (vsbox)

Note that the implementation of vncipher deviates from the RTL in
ISA V2.07.  However it does match the verbal description in the
third paragraph.  The RTL will be fixed in ISA V2.07B.  The
implementation here has been tested against actual P8 hardware.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Binary Coded Decimal Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:16 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Binary Coded Decimal Instructions

This patch add the Binary Coded Decimal instructions bcdadd. and
bcdsub.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Polynomial Multiply Sum
Tom Musta [Wed, 12 Feb 2014 21:23:15 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Polynomial Multiply Sum

This patch adds the Vectory Polynomial Multiply Sum instructions
introduced in Power ISA Version 2.07:

  - Vectory Polynomial Multiply Sum Byte (vpmsumb)
  - Vectory Polynomial Multiply Sum Halfword (vpmsumh)
  - Vectory Polynomial Multiply Sum Word (vpmsumw)
  - Vectory Polynomial Multiply Sum Doubleword (vpmsumd)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Gather Bits by Bytes
Tom Musta [Wed, 12 Feb 2014 21:23:14 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Gather Bits by Bytes

This patch adds the Vector Gather Bits by Bytes Doubleword (vgbbd)
instruction which is introduced in Power ISA Version 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Doubleword Compares
Tom Musta [Wed, 12 Feb 2014 21:23:13 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Doubleword Compares

This patch adds the Vector Compare Doubleword instructions introduced
by Power ISA Version 2.07:

  - Vector Compare Equal to Unsigned Doubleword (vcmpequd)
  - Vector Compare Greater Than Signed Doubleword (vcmpgtsd)
  - Vector Compare Greater Than Unsigned Doubleword (vcmpgtud)

These instructions are encoded with bit 31 set to 1 and so are duals with
vcmpeqfp, vcmpgtfp and vcmpbfp respectively.

The helper macro for integer compares is enhanced to account for 64-bit
operands.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: vbpermq Instruction
Tom Musta [Wed, 12 Feb 2014 21:23:12 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: vbpermq Instruction

This patch adds the Vector Bit Permute Quadword (vbpermq) instruction
introduced in Power ISA Version 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Quadword Addition and Subtracation
Tom Musta [Wed, 12 Feb 2014 21:23:11 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Quadword Addition and Subtracation

This patch adds the Vector Quadword Addition and Subtraction instructions
introduced in Power ISA Version 2.07:

  - Vector Add Unsigned Quadword Modulo (vadduqm)
  - Vector Add & Write Carry Unsigned Quadword (vaddcuq)
  - Vector Add Extended Unsigned Quadword (vaddeuqm)
  - Vector Add Extended & Write Carry Unsigned Quadword (vaddecuq)
  - Vector Subtract Unsigned Quadword Modulo (vsubuqm)
  - Vector Subtract & Write Carry Unsigned Quadword (vsubcuq)
  - Vector Subtract Extended Unsigned Quadword (vsubeuqm)
  - Vector Subtract Extended & Write Carry Unsigned Quadword (vsubecuq)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Doubleword Rotate and Shift Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:10 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Doubleword Rotate and Shift Instructions

This patch adds the vector doublword rotate and shift instructions
introduced in Power ISA Version 2.07:

  - Vector Rotate Left Doubleword instruction (vrld)
  - Vector Shift Left Doubleword (vsld)
  - Vector Shift Right Doubleword (vsrd)
  - Vector Shift Right Algegbraic Doubleword (vsrad)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Change Bit Masks to Support 64-bit Rotates and Shifts
Tom Musta [Wed, 12 Feb 2014 21:23:09 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Change Bit Masks to Support 64-bit Rotates and Shifts

Existing code in the VROTATE, VSL and VSR macros for the Altivec rotate and shift
helpers uses a formula to compute a bit mask used to extract the rotate/shift
amount from the VRB register.  What is desired is:

    mask = (1 << (3 + log2(sizeof(element)))) - 1

but what is implemented is:

    mask = (1 << (3 + (sizeof(element)/2))) - 1

This produces correct answers when "element" is uint8_t, uint16_t or uint_32t.  But
it breaks down when element is uint64_t.

This patch corrects the situation.  Since the mask is known at compile time, the
macros are changed to simply accept the mask as an argument.

Subsequent patches in this series will add double-word variants of rotates and
shifts and thus take advantage of this fix.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Merge Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:08 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Merge Instructions

This patch adds the Vector Merge Even Word (vmrgew) and Vector
Merge Odd Word (vmrgow) instructions introduced in Power ISA
Version 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Unpack Signed Word Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:07 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Unpack Signed Word Instructions

This patch adds the Unpack Signed Word instructions introduced in
Power ISA Version 2.07:

  - Vector Unpack High Signed Word (vupkusw)
  - Vector Unpack Low Signed Word (vupklsw)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Pack Doubleword Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:06 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Pack Doubleword Instructions

This patch adds the Vector Pack Doubleword instructions introduced in
Power ISA Version 2.07:

 - Vector Pack Signed Doubleword Signed Saturate (vpksdss)
 - Vector Pack Signed Doubleword Unsigned Saturate (vpksdus)
 - Vector Pack Unsigned Doubleword Unsigned Modulo (vpkudum)
 - Vector Pack Unsigned Doubleword Unsigned Saturate (vpkudus)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Min/Max Doubleword Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:05 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Min/Max Doubleword Instructions

This patch adds the Vector Minimum and Maximum Doubleword instructions
that are introduced in Power ISA Version 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Population Count Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:04 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Vector Population Count Instructions

This patch adds the Vector Population Count instructions introduced in Power
ISA Version 2.07: vpopcntb, vpopcnth, vpopcntw and vpopcntd.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add Vector Count Leading Zeroes
Tom Musta [Wed, 12 Feb 2014 21:23:03 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Add Vector Count Leading Zeroes

This patch adds the Vector Count Leading Zeroes instructions introduced
in Power ISA Version 2.07 - vclzb, vclzh, vclzw and vclzd.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: vmuluw Instruction
Tom Musta [Wed, 12 Feb 2014 21:23:02 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: vmuluw Instruction

This patch adds the Vector Multiply Unsigned Word Modulo (vmuluwm)
instruction.

The existing VARITH_DO macro is re-used to (trivially) instantiate
the helper code.

Since bits 21-31 of any vmuluwm instruction is 137, the instruction
is coded as a dual to vmulouw (bits 21-31 = 136).

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Multiply Even/Odd Word Instructions
Tom Musta [Wed, 12 Feb 2014 21:23:01 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Multiply Even/Odd Word Instructions

This patch adds the Multilpy Even/Odd Word instructions that are introduced
in Power ISA Version 2.07:

  - Vector Multiply Even Unsigned Word (vmuleuw)
  - Vector Multiply Even Signed Word (vmulesw)
  - Vector Multiply Odd Unsigned Word (vmulouw)
  - Vector Multiply Odd Signed Word (vmulosw)

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Change VMUL_DO to Support 64-bit Integers
Tom Musta [Wed, 12 Feb 2014 21:23:00 +0000 (15:23 -0600)]
target-ppc: Altivec 2.07: Change VMUL_DO to Support 64-bit Integers

This VMUL_DO macro provides support for the various vmule* and vmulo*
instructions.  These instructions multiply vector elements, producing
products that are one size larger; e.g. vmuleub multiplies unsigned 8-bit
elements and produces a 16 bit unsigned element.

The existing macro works correctly for the existing instructions (8-bit,
and 16-bit source elements) but does not work correctly for 32-bit
source elements.

This patch adds an explicit cast to the multiplicands, forcing them to be
of the target element type.  This is required for the forthcoming patches
that add the vmul[eo][us]w instructions.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add/Subtract Unsigned Doubleword Modulo
Tom Musta [Wed, 12 Feb 2014 21:22:59 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Add/Subtract Unsigned Doubleword Modulo

This patch adds two Altivec unsigned doublword modulo instructions that
are introduced in Power ISA Version V2.07:

  - vaddudm : Vector Add Unsigned Doubleword Modulo
  - vsubudm : Vector Subtrace Unsigned Doubleword Modulo

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Vector Logical Instructions
Tom Musta [Wed, 12 Feb 2014 21:22:58 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Vector Logical Instructions

This patch adds the Vector Logical Instructions that are introduced
in Power ISA Version 2.07: veqv, vnand and vorc.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add Support for R-Form Dual Instructions
Tom Musta [Wed, 12 Feb 2014 21:22:57 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Add Support for R-Form Dual Instructions

Some Alitvec instructions introduced in Power ISA Version 2.07 use bit 31
(aka the "Rc" bit) as an opcode but also use bit 21 as an actual Rc
bit.  QEMU for PowerPC typically uses bits 0-5 and 21-30 for opcodes.

This patch introduces a generator macro that injects an auxiliary handler
which decodes both bits 21 and 31 and invokes one of four standard
handlers.  Since the instructions are not, in general, from the same version
of the ISA, two sets of PPC_*/PPC2_* flags are supported.

This patch also introduces a macro to insert two entries into the opcode
table -- one for bit 21 equal to 0 and one for bit 21 equal to 1.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add Opcode Macro for VX Form Instructions
Tom Musta [Wed, 12 Feb 2014 21:22:56 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Add Opcode Macro for VX Form Instructions

This patch adds a macro to insert an entry into the opcode table for Altivec
Power ISA Version 2.07 instructions.  The macro is similar to the GEN_VXFORM macro
except that it tags the entry with the PPC2_ALTIVEC_207 flag rather than
PPC_ALTIVEC.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add Support for Dual Altivec Instructions
Tom Musta [Wed, 12 Feb 2014 21:22:55 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Add Support for Dual Altivec Instructions

Some Alitvec instructions introduced in Power ISA Version 2.07 use bit 31
(aka the "Rc" bit) as an opcode bit.  However, QEMU for PowerPC uses
bits 0-5 and 21-30 for opcodes and not bit 31.

This patch introduces macros that will handle this situation by injecting
an auxiliary handler which decodes bit 31 in invokes one of two standard
handlers.  Since the instructions are not, in general, from the same version
of the ISA, two sets of PPC_*/PPC2_* instruction tags are supported.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add GEN_VXFORM3
Tom Musta [Wed, 12 Feb 2014 21:22:54 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Add GEN_VXFORM3

This patch adds generator macro for Altivec instructions that have 3
source AVR operands.  The macro is similar to the 2 operand form.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Update AVR Structure
Tom Musta [Wed, 12 Feb 2014 21:22:53 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Update AVR Structure

This patch updates the ppc_avr_t data structure to include elements for
signed 64-bit integers and (conditionally) unsigned 128 bit integers.
These elements will be in instructions models later on in this patch series.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Altivec 2.07: Add Instruction Flag
Tom Musta [Wed, 12 Feb 2014 21:22:52 +0000 (15:22 -0600)]
target-ppc: Altivec 2.07: Add Instruction Flag

This patch adds a flag that will be used to tag the Altivec instructions
introduced in Power ISA Version 2.07.

The flag is added to Power8 model since P8 supports these instructions.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add Store Quadword Conditional
Tom Musta [Mon, 10 Feb 2014 17:27:01 +0000 (11:27 -0600)]
target-ppc: Add Store Quadword Conditional

This patch adds the Store Quadword Conditionl (stqcx.) instruction
which is introduced in Power ISA 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
[agraf: fix compile error when !TARGET_PPC64]
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add Load Quadword and Reserve
Tom Musta [Mon, 10 Feb 2014 17:27:00 +0000 (11:27 -0600)]
target-ppc: Add Load Quadword and Reserve

This patch adds the Load Quadword and Reserve (lqarx) instruction,
which is new in Power ISA 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Store Quadword
Tom Musta [Mon, 10 Feb 2014 17:26:59 +0000 (11:26 -0600)]
target-ppc: Store Quadword

This patch adds support for the Store Quadword instruction in user mode.  Prior
to Power ISA 2.07, stq was legal only in privileged mode.  Support for Little
Endian mode is also new in ISA 2.07.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Load Quadword
Tom Musta [Mon, 10 Feb 2014 17:26:58 +0000 (11:26 -0600)]
target-ppc: Load Quadword

This patch adds the Book I (user space) Load Quadword (lq) instruction.
This instruction was introduced into Book I in Power ISA V2.07.  Previous
versions of the architecture supported this as a privileged instruction.
Previous versions of the architecture also did not support Little Endian
mode.

Note that this patch also adds the PPC_64BX flag to the Power8 model,
which enables the lq instruction.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add is_user_mode Utility Routine
Tom Musta [Mon, 10 Feb 2014 17:26:57 +0000 (11:26 -0600)]
target-ppc: Add is_user_mode Utility Routine

This patch adds a boolean function is_user_mode that can be re-used
in translation code that is sensitive to the MSR[PR] (user-mode)
state.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add Flag for ISA 2.07 Load/Store Quadword Instructions
Tom Musta [Mon, 10 Feb 2014 17:26:56 +0000 (11:26 -0600)]
target-ppc: Add Flag for ISA 2.07 Load/Store Quadword Instructions

This patch adds a flag to identify the load/store quadword instructions
that are introduced with Power ISA 2.07.

The flag is added to the Power8 model since P8 supports these
instructions.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add bctar Instruction
Tom Musta [Mon, 10 Feb 2014 17:26:55 +0000 (11:26 -0600)]
target-ppc: Add bctar Instruction

This patch adds the Branch Conditional to Address Register (bctar)
instruction.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add Target Address SPR (TAR) to Power8
Tom Musta [Mon, 10 Feb 2014 17:26:54 +0000 (11:26 -0600)]
target-ppc: Add Target Address SPR (TAR) to Power8

This patch adds support for the Target Address Register (TAR) to the Power8
model.

Because supported SPRs are typically identified in an init_proc_*()
function and because the Power8 model is currently just using the
init_proc_POWER7() function, a new init_proc_POWER8() function
is added and plugged into the P8 model.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add Flag for bctar
Tom Musta [Mon, 10 Feb 2014 17:26:53 +0000 (11:26 -0600)]
target-ppc: Add Flag for bctar

This patch adds a flag for the bctar instruction.  This instruction
is being introduced via Power ISA 2.07.

Also, the flag is added to the Power8 machine model since the P8
processor supports this instruction.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Fix xxpermdi When T==A or T==B
Tom Musta [Mon, 10 Feb 2014 17:25:09 +0000 (11:25 -0600)]
target-ppc: Fix xxpermdi When T==A or T==B

The existing implementation of xxpermdi is defective if the target
VSR is also a source VSR.  This patch fixes the defect in this case
but also preserves the simpler, two TCG operation implementation
when the target is not once of the two sources.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: add extended opcodes for dcbt/dcbtst
Cédric Le Goater [Thu, 20 Feb 2014 13:20:35 +0000 (14:20 +0100)]
target-ppc: add extended opcodes for dcbt/dcbtst

The latest glibc provides a memrchr routine using an extended opcode
of the 'dcbt' instruction :

00000000000a7cc0 <memrchr>:
   a7cc0:       11 00 4c 3c     addis   r2,r12,17
   a7cc4:       b8 f8 42 38     addi    r2,r2,-1864
   a7cc8:       14 2a e3 7c     add     r7,r3,r5
   a7ccc:       d0 00 07 7c     neg     r0,r7
   a7cd0:       ff ff e7 38     addi    r7,r7,-1
   a7cd4:       78 1b 6a 7c     mr      r10,r3
   a7cd8:       24 06 e6 78     rldicr  r6,r7,0,56
   a7cdc:       60 00 20 39     li      r9,96
   a7ce0:       2c 32 09 7e     dcbtt   r9,r6
   ....

which breaks grep, and other commands, in TCG mode :

   invalid bits: 02000000 for opcode: 1f - 16 - 08 (7e09322c00003fff799feca0

This patch adds the extended opcodes for dcbt/dcbtst as no-ops just
like the 'dcbt' instruction.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoqdev: Keep global allocation counter per bus
Alexander Graf [Thu, 6 Feb 2014 15:08:15 +0000 (16:08 +0100)]
qdev: Keep global allocation counter per bus

When we have 2 separate qdev devices that both create a qbus of the
same type without specifying a bus name or device name, we end up
with two buses of the same name, such as ide.0 on the Mac machines:

  dev: macio-ide, id ""
    bus: ide.0
      type IDE
  dev: macio-ide, id ""
    bus: ide.0
      type IDE

If we now spawn a device that connects to a ide.0 the last created
bus gets the device, with the first created bus inaccessible to the
command line.

After some discussion on IRC we concluded that the best quick fix way
forward for this is to make automated bus-class type based allocation
count a global counter. That's what this patch implements. With this
we instead get

  dev: macio-ide, id ""
    bus: ide.1
      type IDE
  dev: macio-ide, id ""
    bus: ide.0
      type IDE

on the example mentioned above.

This also means that if you did -device ...,bus=ide.0 you got a device
on the first bus (the last created one) before this patch and get that
device on the second one (the first created one) now.  Breaks
migration unless you change bus=ide.0 to bus=ide.1 on the destination.

This is intended and makes the bus enumeration work as expected.

As per review request follows a list of otherwise affected boards and
the reasoning for the conclusion that they are ok:

   target      machine         bus id              times
   ------      -------         ------              -----

   aarch64     n800            i2c-bus.0           2
   aarch64     n810            i2c-bus.0           2
   arm         n800            i2c-bus.0           2
   arm         n810            i2c-bus.0           2

-> Devices are only created explicitly on one of the two buses, using
   s->mpu->i2c[0], so no change to the guest.

   aarch64     vexpress-a15    virtio-mmio-bus.0   4
   aarch64     vexpress-a9     virtio-mmio-bus.0   4
   aarch64     virt            virtio-mmio-bus.0   32
   arm         vexpress-a15    virtio-mmio-bus.0   4
   arm         vexpress-a9     virtio-mmio-bus.0   4
   arm         virt            virtio-mmio-bus.0   32

-> Makes -device bus= work for all virtio-mmio buses.  Breaks
   migration.  Workaround for migration from old to new: specify
   virtio-mmio-bus.4 or .32 respectively rather than .0 on the
   destination.

   aarch64     xilinx-zynq-a9  usb-bus.0           2
   arm         xilinx-zynq-a9  usb-bus.0           2
   mips64el    fulong2e        usb-bus.0           2

-> Normal USB operation not affected. Migration driver needs command
   line to use the other bus.

   i386        isapc           ide.0               2
   x86_64      isapc           ide.0               2
   mips        mips            ide.0               2
   mips64      mips            ide.0               2
   mips64el    mips            ide.0               2
   mipsel      mips            ide.0               2
   ppc         g3beige         ide.0               2
   ppc         mac99           ide.0               2
   ppc         prep            ide.0               2
   ppc64       g3beige         ide.0               2
   ppc64       mac99           ide.0               2
   ppc64       prep            ide.0               2

-> Makes -device bus= work for all IDE buses.  Breaks migration.
   Workaround for migration from old to new: specify ide.1 rather than
   ide.0 on the destination.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Andreas Faerber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Update external_htab even when HTAB is managed by kernel
Aneesh Kumar K.V [Tue, 28 Jan 2014 07:59:59 +0000 (13:29 +0530)]
target-ppc: Update external_htab even when HTAB is managed by kernel

We will use this in later patches to make sure we use the right load
functions when copying hpte entries.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: print more detailed error message on failed load_elf()
Alexey Kardashevskiy [Tue, 4 Feb 2014 04:04:19 +0000 (15:04 +1100)]
spapr: print more detailed error message on failed load_elf()

This makes use of new error codes which load_elf() can return and
prints more informative error message.

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