OSDN Git Service

qmiga/qemu.git
6 years agoMerge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.11-20170908' into staging
Peter Maydell [Fri, 8 Sep 2017 13:44:44 +0000 (14:44 +0100)]
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.11-20170908' into staging

ppc patch queue 2017-09-08

This is the first batch of ppc related patches for qemu-2.11, and it's
accumulated quite a few things.  Includes:

  * A cleanup to handling of ppc cpu models from Igor
  * First parts of fixes to handling of guest vs. host SMT modes from
    Sam Bobroff
  * Preliminary patches towards supporting the Sam460 board from
    Balaton Zoltan
  * Several fixes for hotplug logic
  * Assorted other fixes and cleanups

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

* remotes/dgibson/tags/ppc-for-2.11-20170908: (40 commits)
  ppc: spapr: Move VCPU ID calculation into sPAPR
  ppc: remove non implemented cpu models
  ppc: drop caching ObjectClass from PowerPCCPUAlias
  ppc: simplify cpu model lookup by PVR
  ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups
  ppc: make cpu alias point only to real cpu models
  ppc: make cpu_model translation to type consistent
  ppc: use macros to make cpu type name from string literal
  target/ppc: Remove old STATUS file
  PPC: KVM: Support machine option to set VSMT mode
  spapr: fallback to raw mode if best compat mode cannot be set during CAS
  hw/nvram/spapr_nvram: Device can not be created by the users
  hw/ppc/spapr_cpu_core: Add a proper check for spapr machine
  ppc4xx: Export ECB and PLB emulation
  ppc4xx_i2c: Move to hw/i2c
  ppc4xx_i2c: QOMify
  ppc4xx: Split off 4xx I2C emulation from ppc405_uc to its own file
  ppc4xx: Make MAL emulation more generic
  ppc4xx: Move MAL from ppc405_uc to ppc4xx_devs
  spapr_iommu: Realloc guest visible TCE table when hot(un)plugging vfio-pci
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
Peter Maydell [Fri, 8 Sep 2017 11:57:28 +0000 (12:57 +0100)]
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Fri 08 Sep 2017 03:00:34 BST
# gpg:                using RSA key 0xEF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  colo-compare: Update the COLO document to add the IOThread configuration
  colo-compare: Use IOThread to Check old packet regularly and Process pactkets of the primary
  qemu-iothread: IOThread supports the GMainContext event loop
  net/colo-compare.c: Fix comments and scheme
  net/colo-compare.c: Adjust net queue pop order for performance
  net/colo-compare.c: Optimize unpredictable tcp options comparison
  e1000: Rename the SEC symbol to SEQEC
  net/socket: Improve -net socket error reporting
  net/net: Convert parse_host_port() to Error
  net/socket: Convert several helper functions to Error
  net/socket: Don't treat odd socket type as SOCK_STREAM
  MAINTAINERS: Update mail address for COLO Proxy
  net: rtl8139: do not use old_mmio accesses
  net/rocker: Fix the unusual macro name
  net/rocker: Convert to realize()
  net/rocker: Plug memory leak in pci_rocker_init()
  net/rocker: Remove the dead error handling
  net/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20170907' into staging
Peter Maydell [Fri, 8 Sep 2017 10:38:55 +0000 (11:38 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20170907' into staging

TCG constant pools

# gpg: Signature made Thu 07 Sep 2017 23:35:45 BST
# gpg:                using RSA key 0x64DF38E8AF7E215F
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-tcg-20170907: (23 commits)
  tcg/ppc: Use constant pool for movi
  tcg/ppc: Look for shifted constants
  tcg/ppc: Change TCG_REG_RA to TCG_REG_TB
  tcg/arm: Use constant pool for call
  tcg/arm: Use constant pool for movi
  tcg/arm: Extract INSN_NOP
  tcg/arm: Code rearrangement
  tcg/arm: Tighten tlb indexing offset test
  tcg/arm: Improve tlb load for armv7
  tcg/sparc: Use constant pool for movi
  tcg/sparc: Introduce TCG_REG_TB
  tcg/aarch64: Use constant pool for movi
  tcg/s390: Use constant pool for cmpi
  tcg/s390: Use constant pool for xori
  tcg/s390: Use constant pool for ori
  tcg/s390: Use constant pool for andi
  tcg/s390: Use constant pool for movi
  tcg/s390: Fix sign of patch_reloc addend
  tcg/s390: Introduce TCG_REG_TB
  tcg/i386: Store out-of-range call targets in constant pool
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-pa-20170907' into staging
Peter Maydell [Fri, 8 Sep 2017 10:02:54 +0000 (11:02 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-pa-20170907' into staging

Conversion to TranslatorOps

# gpg: Signature made Thu 07 Sep 2017 19:42:48 BST
# gpg:                using RSA key 0x64DF38E8AF7E215F
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-pa-20170907:
  target/hppa: Convert to TranslatorOps
  target/hppa: Convert to DisasContextBase
  target/hppa: Convert to DisasJumpType

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-axp-20170907' into staging
Peter Maydell [Fri, 8 Sep 2017 09:21:54 +0000 (10:21 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20170907' into staging

Queued target/alpha patches

# gpg: Signature made Thu 07 Sep 2017 19:17:22 BST
# gpg:                using RSA key 0x64DF38E8AF7E215F
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-axp-20170907:
  target/alpha: Switch to do_transaction_failed() hook
  target/alpha: Convert to TranslatorOps
  target/alpha: Convert to DisasContextBase
  target/alpha: Convert to DisasJumpType

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agocolo-compare: Update the COLO document to add the IOThread configuration
Wang Yong [Tue, 29 Aug 2017 07:22:39 +0000 (15:22 +0800)]
colo-compare: Update the COLO document to add the IOThread configuration

Update colo-proxy.txt,add IOThread configuration.
Later we have to configure IOThread,if not COLO can not work.

Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agocolo-compare: Use IOThread to Check old packet regularly and Process pactkets of...
Wang Yong [Tue, 29 Aug 2017 07:22:38 +0000 (15:22 +0800)]
colo-compare: Use IOThread to Check old packet regularly and Process pactkets of the primary

Remove the task which check old packet in the comparing thread,
then use IOthread context timer to handle it.

Process pactkets in the IOThread which arrived over the socket.
we use iothread_get_g_main_context to create a new g_main_loop in
the IOThread.then the packets from the primary and the secondary
are processed in the IOThread.

Finally remove the colo-compare thread using the IOThread instead.

Reviewed-by: Zhang Chen<zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agoqemu-iothread: IOThread supports the GMainContext event loop
Wang Yong [Tue, 29 Aug 2017 07:22:37 +0000 (15:22 +0800)]
qemu-iothread: IOThread supports the GMainContext event loop

IOThread uses AioContext event loop and does not run a GMainContext.
Therefore,chardev cannot work in IOThread,such as the chardev is
used for colo-compare packets reception.

This patch makes the IOThread run the GMainContext event loop,
chardev and IOThread can work together.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/colo-compare.c: Fix comments and scheme
Zhang Chen [Tue, 5 Sep 2017 06:31:06 +0000 (14:31 +0800)]
net/colo-compare.c: Fix comments and scheme

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/colo-compare.c: Adjust net queue pop order for performance
Zhang Chen [Tue, 5 Sep 2017 06:31:05 +0000 (14:31 +0800)]
net/colo-compare.c: Adjust net queue pop order for performance

The packet_enqueue() use g_queue_push_tail() to
enqueue net packet, so it is more efficent way use
g_queue_pop_head() to get packet for compare.
That will improve the success rate of comparison.
In my test the performance of ftp put 1000M file
will increase 10%

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/colo-compare.c: Optimize unpredictable tcp options comparison
Zhang Chen [Tue, 5 Sep 2017 06:31:04 +0000 (14:31 +0800)]
net/colo-compare.c: Optimize unpredictable tcp options comparison

When network is busy, some tcp options(like sack) will unpredictable
occur in primary side or secondary side. it will make packet size
not same, but the two packet's payload is identical. colo just
care about packet payload, so we skip the option field.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agoe1000: Rename the SEC symbol to SEQEC
Kamil Rytarowski [Sun, 3 Sep 2017 16:37:26 +0000 (18:37 +0200)]
e1000: Rename the SEC symbol to SEQEC

SunOS defines SEC in <sys/time.h> as 1 (commonly used time symbols).

This fixes build on SmartOS (Joyent).

Patch cherry-picked from pkgsrc by jperkin (Joyent).

Signed-off-by: Kamil Rytarowski <n54@gmx.com>
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/socket: Improve -net socket error reporting
Mao Zhongyi [Mon, 4 Sep 2017 14:35:40 +0000 (22:35 +0800)]
net/socket: Improve -net socket error reporting

When -net socket fails, it first reports a specific error, then
a generic one, like this:

    $ ./x86_64-softmmu/qemu-system-x86_64 -net socket,mcast=230.0.0.1:1234,listen
    qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: exactly one of listen=, connect=, mcast= or udp= is required
    qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: Device 'socket' could not be initialized

Convert net_socket_*_init() to Error to get rid of the superfluous second
error message. After the patch, the effect like this:

    $ ./x86_64-softmmu/qemu-system-x86_64 -net socket,mcast=230.0.0.1:1234,listen
    qemu-system-x86_64: -net socket,mcast=230.0.0.1:1234,listen: exactly one of listen=, connect=, mcast= or udp= is requireda

This also fixes a few silent failures to report an error.

Cc: jasowang@redhat.com
Cc: armbru@redhat.com
Cc: berrange@redhat.com
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/net: Convert parse_host_port() to Error
Mao Zhongyi [Mon, 4 Sep 2017 14:35:39 +0000 (22:35 +0800)]
net/net: Convert parse_host_port() to Error

Cc: berrange@redhat.com
Cc: kraxel@redhat.com
Cc: pbonzini@redhat.com
Cc: jasowang@redhat.com
Cc: armbru@redhat.com
Cc: eblake@redhat.com
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/socket: Convert several helper functions to Error
Mao Zhongyi [Mon, 4 Sep 2017 14:35:38 +0000 (22:35 +0800)]
net/socket: Convert several helper functions to Error

Currently, net_socket_mcast_create(), net_socket_fd_init_dgram() and
net_socket_fd_init() use the function such as fprintf(), perror() to
report an error message.

Now, convert these functions to Error.

Cc: jasowang@redhat.com
Cc: armbru@redhat.com
Cc: berrange@redhat.com
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/socket: Don't treat odd socket type as SOCK_STREAM
Mao Zhongyi [Mon, 4 Sep 2017 14:35:37 +0000 (22:35 +0800)]
net/socket: Don't treat odd socket type as SOCK_STREAM

In net_socket_fd_init(), the 'default' case is odd: it warns,
then continues as if the socket type was SOCK_STREAM. The
comment explains "this could be a eg. a pty", but that makes
no sense. If @fd really was a pty, getsockopt() would fail
with ENOTSOCK. If @fd was a socket, but neither SOCK_DGRAM nor
SOCK_STREAM. It should not be treated as if it was SOCK_STREAM.

Turn this case into an Error. If there is a genuine reason to
support something like SOCK_RAW, it should be explicitly
handled.

Cc: jasowang@redhat.com
Cc: armbru@redhat.com
Cc: berrange@redhat.com
Cc: armbru@redhat.com
Cc: eblake@redhat.com
Suggested-by: Markus Armbruster <armbru@redhat.com>
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agoMAINTAINERS: Update mail address for COLO Proxy
Zhang Chen [Wed, 23 Aug 2017 08:51:57 +0000 (16:51 +0800)]
MAINTAINERS: Update mail address for COLO Proxy

My Fujitsu mail account will be disabled soon, update the mail info
to my private mail.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet: rtl8139: do not use old_mmio accesses
Matt Parker [Tue, 15 Aug 2017 20:06:07 +0000 (21:06 +0100)]
net: rtl8139: do not use old_mmio accesses

Both io and memory use the same mmio functions in the rtl8139 device.
This patch removes the separate MemoryRegionOps and old_mmio accessors
for memory, and replaces it with an alias to the io memory region.

Signed-off-by: Matt Parker <mtparkr@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/rocker: Fix the unusual macro name
Mao Zhongyi [Mon, 14 Aug 2017 03:33:10 +0000 (11:33 +0800)]
net/rocker: Fix the unusual macro name

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/rocker: Convert to realize()
Mao Zhongyi [Mon, 14 Aug 2017 03:33:09 +0000 (11:33 +0800)]
net/rocker: Convert to realize()

The rocker device still implements the old PCIDeviceClass .init()
instead of the new .realize(). All devices need to be converted to
.realize().

.init() reports errors with fprintf() and return 0 on success, negative
number on failure. Meanwhile, when -device rocker fails, it first report
a specific error, then a generic one, like this:

    $ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
    rocker: name too long; please shorten to at most 9 chars
    qemu-system-x86_64: -device rocker,name=qemu-rocker: Device initialization failed

Now, convert it to .realize() that passes errors to its callers via its
errp argument. Also avoid the superfluous second error message. After
the patch, effect like this:

    $ x86_64-softmmu/qemu-system-x86_64 -device rocker,name=qemu-rocker
    qemu-system-x86_64: -device rocker,name=qemu-rocker: name too long; please shorten to at most 9 chars

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/rocker: Plug memory leak in pci_rocker_init()
Mao Zhongyi [Mon, 14 Aug 2017 03:33:08 +0000 (11:33 +0800)]
net/rocker: Plug memory leak in pci_rocker_init()

pci_rocker_init() leaks a World when the name more than 9 chars,
then return a negative value directly, doesn't make a correct
cleanup. So add a new goto label to fix it.

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/rocker: Remove the dead error handling
Mao Zhongyi [Mon, 14 Aug 2017 03:33:07 +0000 (11:33 +0800)]
net/rocker: Remove the dead error handling

Memory allocation functions like world_alloc, desc_ring_alloc etc,
they are all wrappers around g_malloc, g_new etc. But g_malloc and
similar functions doesn't return null. Because they ignore the fact
that g_malloc() of 0 bytes returns null. So error checks for these
allocation failure are superfluous. Now, remove them entirely.

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agonet/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net
Zhang Chen [Fri, 28 Jul 2017 10:03:10 +0000 (18:03 +0800)]
net/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net

Because vnet_hdr have a offset to net packet, we must add it when use
virtio-net.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
6 years agoppc: spapr: Move VCPU ID calculation into sPAPR
Sam Bobroff [Thu, 31 Aug 2017 06:38:46 +0000 (16:38 +1000)]
ppc: spapr: Move VCPU ID calculation into sPAPR

Move the calculation of a CPU's VCPU ID out of the generic PPC code
(ppc_cpu_realizefn()) and into sPAPR specific code
(spapr_cpu_core_realize()) where it belongs.

Unfortunately, due to the way things are ordered, we still need to
default the VCPU ID in ppc_cpu_realizfn() but at least doing that
doesn't require any interaction with sPAPR.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: remove non implemented cpu models
Igor Mammedov [Wed, 30 Aug 2017 13:24:35 +0000 (15:24 +0200)]
ppc: remove non implemented cpu models

Remove cpu models that aren't implemented and are not
compiled/tested since they are under TODO ifdef
which isn't defined in sources.

If someone really needs a removed model he/she should add
as regular one with corresponding implementation.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: drop caching ObjectClass from PowerPCCPUAlias
Igor Mammedov [Wed, 30 Aug 2017 13:24:34 +0000 (15:24 +0200)]
ppc: drop caching ObjectClass from PowerPCCPUAlias

Caching there practically doesn't give any benefits
and that at slow path druring querying supported CPU list.
But it introduces non conventional path of where from
comes used CPU type name (kvm_ppc_register_host_cpu_type).

Taking in account that kvm_ppc_register_host_cpu_type()
fixes up models the aliases point to, it's sufficient to
make ppc_cpu_class_by_name() translate cpu alias to
correct cpu type name.
So drop PowerPCCPUAlias::oc field + ppc_cpu_class_by_alias()
and let ppc_cpu_class_by_name() do conversion to cpu type name,
which simplifies code a little bit saving ~20LOC and trouble
wondering why ppc_cpu_class_by_alias() is necessary.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: simplify cpu model lookup by PVR
Igor Mammedov [Wed, 30 Aug 2017 13:24:33 +0000 (15:24 +0200)]
ppc: simplify cpu model lookup by PVR

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups
Igor Mammedov [Wed, 30 Aug 2017 13:24:32 +0000 (15:24 +0200)]
ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups

previous patches cleaned up cpu model/alias naming which
allows to simplify cpu model/alias to cpu type lookup a bit
byt removing recurssion and dependency of ppc_cpu_class_by_name() /
ppc_cpu_class_by_alias() on each other.
Besides of simplifying code it reduces it by ~15LOC.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: make cpu alias point only to real cpu models
Igor Mammedov [Wed, 30 Aug 2017 13:24:31 +0000 (15:24 +0200)]
ppc: make cpu alias point only to real cpu models

alias pointing to another alias forces lookup code to
do recurrsive translation till real cpu model is reached.

Drop this nonsence and make each alias point to cpu model
that has corresponding CPU type. It will allow to drop
recurrsion in cpu model translation code and actually
make ppc_cpu_aliases[] content use PowerPCCPUAlias
fields properly
(i.e. alias goes into .alias and model goes into .model)

While at it add TODO defines around aliases that point to
cpu models excluded by the same TODO defines.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: make cpu_model translation to type consistent
Igor Mammedov [Wed, 30 Aug 2017 13:24:30 +0000 (15:24 +0200)]
ppc: make cpu_model translation to type consistent

PPC handles -cpu FOO rather incosistently,
i.e. it does case-insensitive matching of FOO to
a CPU type (see: ppc_cpu_compare_class_name) but
handles alias names as case-sensitive, as result:

 # qemu-system-ppc64 -M mac99 -cpu g3
 qemu-system-ppc64: unable to find CPU model ' kN�U'

 # qemu-system-ppc64 -cpu 970MP_V1.1
 qemu-system-ppc64: Unable to find sPAPR CPU Core definition

while

 # qemu-system-ppc64 -M mac99 -cpu G3
 # qemu-system-ppc64 -cpu 970MP_v1.1

start up just fine.

Considering we can't take case-insensitive matching away,
make it case-insensitive for  all alias/type/core_type
lookups.

As side effect it allows to remove duplicate core types
which are the same except of using different cased letters in name.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: use macros to make cpu type name from string literal
Igor Mammedov [Wed, 30 Aug 2017 13:24:29 +0000 (15:24 +0200)]
ppc: use macros to make cpu type name from string literal

Replace
  "-" TYPE_POWERPC_CPU
when composing cpu type name from cpu model string literal
and the same pattern in format strings with
 POWERPC_CPU_TYPE_SUFFIX and POWERPC_CPU_TYPE_NAME(model)
macroses like we do in x86.

Later POWERPC_CPU_TYPE_NAME() will be used to define default
cpu type per machine type and as bonus it will be consistent
and easy grep-able pattern across all other targets that I'm
plannig to treat the same way.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agotarget/ppc: Remove old STATUS file
Thomas Huth [Fri, 1 Sep 2017 07:38:12 +0000 (09:38 +0200)]
target/ppc: Remove old STATUS file

The target/ppc/STATUS file has seen its last real update 10 years
ago - so the information in there is not up to date anymore. Since
nobody seems to care about this file, let's simply remove it.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoPPC: KVM: Support machine option to set VSMT mode
Sam Bobroff [Fri, 18 Aug 2017 05:50:22 +0000 (15:50 +1000)]
PPC: KVM: Support machine option to set VSMT mode

KVM now allows writing to KVM_CAP_PPC_SMT which has previously been
read only. Doing so causes KVM to act, for that VM, as if the host's
SMT mode was the given value. This is particularly important on Power
9 systems because their default value is 1, but they are able to
support values up to 8.

This patch introduces a way to control this capability via a new
machine property called VSMT ("Virtual SMT"). If the value is not set
on the command line a default is chosen that is, when possible,
compatible with legacy systems.

Note that the intialization of KVM_CAP_PPC_SMT has changed slightly
because it has changed (in KVM) from a global capability to a
VM-specific one. This won't cause a problem on older KVMs because VM
capabilities fall back to global ones.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr: fallback to raw mode if best compat mode cannot be set during CAS
Greg Kurz [Thu, 17 Aug 2017 11:23:50 +0000 (13:23 +0200)]
spapr: fallback to raw mode if best compat mode cannot be set during CAS

KVM PR doesn't allow to set a compat mode. This causes ppc_set_compat_all()
to fail and we return H_HARDWARE to the guest right away.

This is excessive: even if we favor compat mode since commit 152ef803ceb19,
we should at least fallback to raw mode if the guest supports it.

This patch modifies cas_check_pvr() so that it also reports that the real
PVR was found in the table supplied by the guest. Note that this is only
makes sense if raw mode isn't explicitely disabled (ie, the user didn't
set the machine "max-cpu-compat" property). If this is the case, we can
simply ignore ppc_set_compat_all() failures, and let the guest run in raw
mode.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agohw/nvram/spapr_nvram: Device can not be created by the users
Thomas Huth [Thu, 24 Aug 2017 07:41:33 +0000 (09:41 +0200)]
hw/nvram/spapr_nvram: Device can not be created by the users

Trying to add a spapr-nvram device currently aborts QEMU like this:

$ ppc64-softmmu/qemu-system-ppc64  -device spapr-nvram
qemu-system-ppc64: hw/ppc/spapr_rtas.c:407: spapr_rtas_register:
 Assertion `!rtas_table[token].name' failed.
Aborted (core dumped)

This NVRAM device registers RTAS calls during its realize function
and thus can only be used once - and that's internally from spapr.c.
So let's mark the device with user_creatable = false to avoid that
the users can crash their QEMU this way.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agohw/ppc/spapr_cpu_core: Add a proper check for spapr machine
Thomas Huth [Thu, 24 Aug 2017 03:52:32 +0000 (05:52 +0200)]
hw/ppc/spapr_cpu_core: Add a proper check for spapr machine

QEMU currently crashes when the user tries to add a spapr-cpu-core
on a non-pseries machine:

$ qemu-system-ppc64 -S -machine ppce500,accel=tcg \
                    -device POWER5+_v2.1-spapr-cpu-core
hw/ppc/spapr_cpu_core.c:178:spapr_cpu_core_realize_child:
Object 0x55cee1f55160 is not an instance of type spapr-machine
Aborted (core dumped)

So let's add a proper check for the correct machine time with
a more friendly error message here.

Reported-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc4xx: Export ECB and PLB emulation
BALATON Zoltan [Sun, 20 Aug 2017 17:23:05 +0000 (19:23 +0200)]
ppc4xx: Export ECB and PLB emulation

Make these device models available outside ppc405_uc.c for reuse in
460EX emulation. They are left in their current place for now because
they are used mostly unchanged and I'm not sure these correctly model
the components in 440 SoCs (but they seem to be good enough). These
functions could be moved in a subsequent clean up series when this is
confirmed.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc4xx_i2c: Move to hw/i2c
BALATON Zoltan [Sun, 20 Aug 2017 17:23:05 +0000 (19:23 +0200)]
ppc4xx_i2c: Move to hw/i2c

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc4xx_i2c: QOMify
BALATON Zoltan [Sun, 20 Aug 2017 17:23:05 +0000 (19:23 +0200)]
ppc4xx_i2c: QOMify

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc4xx: Split off 4xx I2C emulation from ppc405_uc to its own file
BALATON Zoltan [Sun, 20 Aug 2017 17:23:05 +0000 (19:23 +0200)]
ppc4xx: Split off 4xx I2C emulation from ppc405_uc to its own file

This device appears in other SoCs as well not just in 405 ones and
subsequent patches will modify it, so move it out of ppc405_uc.c in
preparation

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc4xx: Make MAL emulation more generic
BALATON Zoltan [Sun, 20 Aug 2017 17:23:05 +0000 (19:23 +0200)]
ppc4xx: Make MAL emulation more generic

Allow MAL with more RX and TX channels as found in newer versions.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc4xx: Move MAL from ppc405_uc to ppc4xx_devs
BALATON Zoltan [Sun, 20 Aug 2017 17:23:05 +0000 (19:23 +0200)]
ppc4xx: Move MAL from ppc405_uc to ppc4xx_devs

This device appears in other SoCs as well not just in 405 ones

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_iommu: Realloc guest visible TCE table when hot(un)plugging vfio-pci
Alexey Kardashevskiy [Thu, 20 Jul 2017 07:22:29 +0000 (17:22 +1000)]
spapr_iommu: Realloc guest visible TCE table when hot(un)plugging vfio-pci

This replaces g_malloc() with spapr_tce_alloc_table() as this is
the standard way of allocating tables and this allows moving the table
back to KVM when unplugging a VFIO PCI device and VFIO TCE acceleration
support is not present in the KVM.

Although spapr_tce_alloc_table() is expected to fail with EBUSY
if called when previous fd is not closed yet, in practice we will not
see it because cap_spapr_vfio is false at the moment.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc64: introduce e6500
KONRAD Frederic [Mon, 7 Aug 2017 15:50:48 +0000 (17:50 +0200)]
ppc64: introduce e6500

This introduces e6500 core.

Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agobooke206: allow to specify an mmucfg value at the init
KONRAD Frederic [Mon, 7 Aug 2017 15:50:47 +0000 (17:50 +0200)]
booke206: allow to specify an mmucfg value at the init

This allows to init the MMUCFG SPR with a non NULL value.

Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agobooke206: fix tlbnps for fixed size TLB
KONRAD Frederic [Mon, 7 Aug 2017 15:50:46 +0000 (17:50 +0200)]
booke206: fix tlbnps for fixed size TLB

Some OS don't populate the TSIZE field when using a fixed size TLB which result
in a 1KB TLB. When the TLB is a fixed size TLB the TSIZE field should be
ignored.

Fix this wrong behavior with MAV 2.0.

Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agobooke206: fix booke206_tlbnps for mav 2.0
KONRAD Frederic [Mon, 7 Aug 2017 15:50:45 +0000 (17:50 +0200)]
booke206: fix booke206_tlbnps for mav 2.0

This fixes booke206_tlbnps for MAV 2.0 by checking the MMUCFG register and
return directly the right tlbnps instead of computing it from non existing
field.

Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: spapr: Make VCPU ID handling private to SPAPR
Sam Bobroff [Wed, 9 Aug 2017 05:38:56 +0000 (15:38 +1000)]
ppc: spapr: Make VCPU ID handling private to SPAPR

The concept of a VCPU ID that differs from the CPU's index
(cpu->cpu_index) exists only within SPAPR machines so, move the
functions ppc_get_vcpu_id() and ppc_get_cpu_by_vcpu_id() into spapr.c
and rename them appropriately.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoppc: spapr: Rename cpu_dt_id to vcpu_id
Sam Bobroff [Thu, 3 Aug 2017 06:28:44 +0000 (16:28 +1000)]
ppc: spapr: Rename cpu_dt_id to vcpu_id

This field actually records the VCPU ID used by KVM and, although the
value is also used in the device tree it is primarily the VCPU ID so
rename it as such.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
[dwg: Updated comment missed in cpu.h]
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agoe500: Use cpu_index instead of vcpu_dt_id
Sam Bobroff [Thu, 3 Aug 2017 06:28:36 +0000 (16:28 +1000)]
e500: Use cpu_index instead of vcpu_dt_id

The e500 platform code uses the function ppc_get_vcpu_dt_id() to get
an id to put in its device tree.  Which seems like it makes sense, but
ppc_get_vcpu_dt_id() is actually badly named - it only differs from
cpu_index in cases where you're running on KVM HV and the host's
number of threads differs from the guests.  Since KVM HV only supports
PAPR, not e500, it doesn't make sense to use it here.

Simply use the cpu_index instead (which is 'i' in this context
because qemu_get_cpu(i) returns the cpu with cpu_index == i).

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
[dwg: Rewrote commit message]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr: add pseries-2.11 machine type
Greg Kurz [Tue, 25 Jul 2017 18:01:12 +0000 (20:01 +0200)]
spapr: add pseries-2.11 machine type

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_iommu: unregister vmstate at unrealize time
Greg Kurz [Tue, 25 Jul 2017 18:00:22 +0000 (20:00 +0200)]
spapr_iommu: unregister vmstate at unrealize time

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_iommu: pass object ownership to parent/owner
Michael Roth [Tue, 25 Jul 2017 18:00:09 +0000 (20:00 +0200)]
spapr_iommu: pass object ownership to parent/owner

TCE table objects attach themselves to an owner as a child
property. unref afterward to allow them to be finalized
when their owner is finalized.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_drc: pass object ownership to parent/owner
Michael Roth [Tue, 25 Jul 2017 17:59:56 +0000 (19:59 +0200)]
spapr_drc: pass object ownership to parent/owner

DRC objects attach themselves to an owner as a child
property. unref afterward to allow them to be finalized
when their owner is finalized.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_drc: add unrealize method to physical DRC class
Greg Kurz [Tue, 25 Jul 2017 17:59:44 +0000 (19:59 +0200)]
spapr_drc: add unrealize method to physical DRC class

When hot-unplugging a PHB, all its PCI DRC connectors get unrealized. This
patch adds an unrealize method to the physical DRC class, in order to undo
registrations performed in realize_physical().

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_pci: parent the MSI memory region to the PHB
Greg Kurz [Tue, 25 Jul 2017 17:59:18 +0000 (19:59 +0200)]
spapr_pci: parent the MSI memory region to the PHB

This memory region should be owned by the PHB. This ensures the PHB
cannot be finalized as long as the the region is guest visible, or
used by a CPU or a device.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_iommu: convert TCE table object to realize()
Greg Kurz [Tue, 25 Jul 2017 17:59:06 +0000 (19:59 +0200)]
spapr_iommu: convert TCE table object to realize()

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_drc: use g_strdup_printf() instead of snprintf()
Greg Kurz [Tue, 25 Jul 2017 17:58:53 +0000 (19:58 +0200)]
spapr_drc: use g_strdup_printf() instead of snprintf()

Passing a stack allocated buffer of arbitrary length to snprintf()
without checking the return value can cause the resultant strings
to be silently truncated.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_iommu: use g_strdup_printf() instead of snprintf()
Greg Kurz [Tue, 25 Jul 2017 17:58:40 +0000 (19:58 +0200)]
spapr_iommu: use g_strdup_printf() instead of snprintf()

Passing a stack allocated buffer of arbitrary length to snprintf()
without checking the return value can cause the resultant strings
to be silently truncated.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agospapr_pci: use memory_region_add_subregion() with DMA windows
Greg Kurz [Tue, 25 Jul 2017 17:58:28 +0000 (19:58 +0200)]
spapr_pci: use memory_region_add_subregion() with DMA windows

Passing a null priority to memory_region_add_subregion_overlap() is
strictly equivalent to calling memory_region_add_subregion().

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agohw/ppc: CAS reset on early device hotplug
Daniel Henrique Barboza [Wed, 30 Aug 2017 18:21:41 +0000 (15:21 -0300)]
hw/ppc: CAS reset on early device hotplug

This patch is a follow up on the discussions made in patch
"hw/ppc: disable hotplug before CAS is completed" that can be
found at [1].

At this moment, we do not support CPU/memory hotplug in early
boot stages, before CAS. When a hotplug occurs, the event is logged
in an internal RTAS event log queue and an IRQ pulse is fired. In
regular conditions, the guest handles the interrupt by executing
check_exception, fetching the generated hotplug event and enabling
the device for use.

In early boot, this IRQ isn't caught (SLOF does not handle hotplug
events), leaving the event in the rtas event log queue. If the guest
executes check_exception due to another hotplug event, the re-assertion
of the IRQ ends up de-queuing the first hotplug event as well. In short,
a device hotplugged before CAS is considered coldplugged by SLOF.
This leads to device misbehavior and, in some cases, guest kernel
Ooops when trying to unplug the device.

A proper fix would be to turn every device hotplugged before CAS
as a colplugged device. This is not trivial to do with the current
code base though - the FDT is written in the guest memory at
ppc_spapr_reset and can't be retrieved without adding extra state
(fdt_size for example) that will need to managed and migrated. Adding
the hotplugged DT in the middle of CAS negotiation via the updated DT
tree works with CPU devs, but panics the guest kernel at boot. Additional
analysis would be necessary for LMBs and PCI devices. There are
questions to be made in QEMU/SLOF/kernel level about how we can make
this change in a sustainable way.

With Linux guests, a fix would be the kernel executing check_exception
at boot time, de-queueing the events that happened in early boot and
processing them. However, even if/when the newer kernels start
fetching these events at boot time, we need to take care of older
kernels that won't be doing that.

This patch works around the situation by issuing a CAS reset if a hotplugged
device is detected during CAS:

- the DRC conditions that warrant a CAS reset is the same as those that
triggers a DRC migration - the DRC must have a device attached and
the DRC state is not equal to its ready_state. With that in mind, this
patch makes use of 'spapr_drc_needed' to determine if a CAS reset
is needed.

- In the middle of CAS negotiations, the function
'spapr_hotplugged_dev_before_cas' goes through all the DRCs to see
if there are any DRC that requires a reset, using spapr_drc_needed. If
that happens, returns '1' in 'spapr_h_cas_compose_response' which will set
spapr->cas_reboot to true, causing the machine to reboot.

No changes are made for coldplug devices.

[1] http://lists.nongnu.org/archive/html/qemu-devel/2017-08/msg02855.html

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agohw/ppc: clear pending_events on machine reset
Daniel Henrique Barboza [Wed, 30 Aug 2017 18:21:40 +0000 (15:21 -0300)]
hw/ppc: clear pending_events on machine reset

The sPAPR machine isn't clearing up the pending events QTAILQ on
machine reboot. This allows for unprocessed hotplug/epow events
to persist in the queue after reset and, when reasserting the IRQs in
check_exception later on, these will be being processed by the OS.

This patch implements a new function called 'spapr_clear_pending_events'
that clears up the pending_events QTAILQ. This helper is then called
inside ppc_spapr_reset to clear up the events queue, preventing
old/deprecated events from persisting after a reset.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agohw/ppc/spapr_drc.c: change spapr_drc_needed to use drc->dev
Daniel Henrique Barboza [Wed, 30 Aug 2017 18:21:39 +0000 (15:21 -0300)]
hw/ppc/spapr_drc.c: change spapr_drc_needed to use drc->dev

This patch makes a small fix in 'spapr_drc_needed' to change how we detect
if a DRC has a device attached. Previously it used dr_entity_sense for this,
which  works for physical DRCs.

However, for logical DRCs, it didn't cover the case where a logical DRC has
a drc->dev but the state is LOGICAL_UNUSABLE (e.g. a hotplugged CPU before
CAS). In this case, the dr_entity_sense of this DRC returns UNUSABLE and the
code was considering that there were no dev attached, making spapr_drc_needed
return 'false' when in fact we would like to migrate the DRC.

Changing it to check for drc->dev instead works for all DRC types.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
6 years agotcg/ppc: Use constant pool for movi
Richard Henderson [Mon, 31 Jul 2017 06:03:03 +0000 (06:03 +0000)]
tcg/ppc: Use constant pool for movi

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/ppc: Look for shifted constants
Richard Henderson [Mon, 31 Jul 2017 04:54:02 +0000 (04:54 +0000)]
tcg/ppc: Look for shifted constants

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/ppc: Change TCG_REG_RA to TCG_REG_TB
Richard Henderson [Mon, 31 Jul 2017 04:16:10 +0000 (04:16 +0000)]
tcg/ppc: Change TCG_REG_RA to TCG_REG_TB

At this point the conversion is a wash.  Loading of TB+ofs is
smaller, but the actual return address from exit_tb is larger.
There are a few more insns required to transition between TBs.

But the expectation is that accesses to the constant pool will
on the whole be smaller.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/arm: Use constant pool for call
Richard Henderson [Fri, 28 Jul 2017 04:12:24 +0000 (21:12 -0700)]
tcg/arm: Use constant pool for call

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/arm: Use constant pool for movi
Richard Henderson [Fri, 28 Jul 2017 03:47:56 +0000 (20:47 -0700)]
tcg/arm: Use constant pool for movi

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/arm: Extract INSN_NOP
Richard Henderson [Fri, 28 Jul 2017 03:45:38 +0000 (20:45 -0700)]
tcg/arm: Extract INSN_NOP

We'll want this for tcg_out_nop_fill.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/arm: Code rearrangement
Richard Henderson [Fri, 28 Jul 2017 03:43:30 +0000 (20:43 -0700)]
tcg/arm: Code rearrangement

Move constants before all of the functions.
Move tcg_out_<format> functions before all
of the others.  No functional change.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/arm: Tighten tlb indexing offset test
Richard Henderson [Thu, 27 Jul 2017 20:26:33 +0000 (13:26 -0700)]
tcg/arm: Tighten tlb indexing offset test

We are not going to use ldrd for loading the comparator
for 32-bit guests, so don't limit cmp_off to 8 bits then.
This eliminates one insn in the tlb load for some guests.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/arm: Improve tlb load for armv7
Richard Henderson [Thu, 27 Jul 2017 20:16:16 +0000 (13:16 -0700)]
tcg/arm: Improve tlb load for armv7

Use UBFX to avoid limitation on CPU_TLB_BITS.  Since we're dropping
the initial shift, we need to replace the page masking.  We can use
MOVW+BIC to do this without shifting.  The result is the same size
as the armv6 path with one less conditional instruction.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/sparc: Use constant pool for movi
Richard Henderson [Wed, 26 Jul 2017 18:30:35 +0000 (21:30 +0300)]
tcg/sparc: Use constant pool for movi

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/sparc: Introduce TCG_REG_TB
Richard Henderson [Wed, 26 Jul 2017 17:27:55 +0000 (20:27 +0300)]
tcg/sparc: Introduce TCG_REG_TB

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/aarch64: Use constant pool for movi
Richard Henderson [Wed, 26 Jul 2017 07:29:49 +0000 (00:29 -0700)]
tcg/aarch64: Use constant pool for movi

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Use constant pool for cmpi
Richard Henderson [Wed, 26 Jul 2017 00:10:29 +0000 (20:10 -0400)]
tcg/s390: Use constant pool for cmpi

Also use CHI/CGHI for 16-bit signed constants.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Use constant pool for xori
Richard Henderson [Tue, 25 Jul 2017 23:42:51 +0000 (19:42 -0400)]
tcg/s390: Use constant pool for xori

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Use constant pool for ori
Richard Henderson [Tue, 25 Jul 2017 23:21:36 +0000 (19:21 -0400)]
tcg/s390: Use constant pool for ori

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Use constant pool for andi
Richard Henderson [Tue, 25 Jul 2017 22:59:13 +0000 (18:59 -0400)]
tcg/s390: Use constant pool for andi

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Use constant pool for movi
Richard Henderson [Tue, 1 Aug 2017 02:16:02 +0000 (19:16 -0700)]
tcg/s390: Use constant pool for movi

Split out maybe_out_small_movi for use with other operations
that want to add to the constant pool.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Fix sign of patch_reloc addend
Richard Henderson [Sun, 30 Jul 2017 20:58:01 +0000 (13:58 -0700)]
tcg/s390: Fix sign of patch_reloc addend

We were passing in -2 instead of +2, but then ignoring
the actual contents of addend in the calculation.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/s390: Introduce TCG_REG_TB
Richard Henderson [Tue, 25 Jul 2017 18:53:50 +0000 (11:53 -0700)]
tcg/s390: Introduce TCG_REG_TB

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg/i386: Store out-of-range call targets in constant pool
Richard Henderson [Fri, 21 Jul 2017 05:56:42 +0000 (19:56 -1000)]
tcg/i386: Store out-of-range call targets in constant pool

Already it saves 2 bytes per call, but also the constant pool
entry may well be shared across multiple calls.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg: Infrastructure for managing constant pools
Richard Henderson [Sun, 30 Jul 2017 20:13:21 +0000 (13:13 -0700)]
tcg: Infrastructure for managing constant pools

A new shared header tcg-pool.inc.c adds new_pool_label,
for registering a tcg_target_ulong to be emitted after
the generated code, plus relocation data to install a
pointer to the data.

A new pointer is added to the TCGContext, so that we
dump the constant pool as data, not code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg: Rearrange ldst label tracking
Richard Henderson [Sun, 30 Jul 2017 19:30:41 +0000 (12:30 -0700)]
tcg: Rearrange ldst label tracking

Dispense with TCGBackendData, as it has never been used for more than
holding a single pointer.  Use a define in the cpu/tcg-target.h to
signal requirement for TCGLabelQemuLdst, so that we can drop the no-op
tcg-be-null.h stubs.  Rename tcg-be-ldst.h to tcg-ldst.inc.c.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotcg: Move USE_DIRECT_JUMP discriminator to tcg/cpu/tcg-target.h
Richard Henderson [Tue, 1 Aug 2017 05:02:31 +0000 (22:02 -0700)]
tcg: Move USE_DIRECT_JUMP discriminator to tcg/cpu/tcg-target.h

Replace the USE_DIRECT_JUMP ifdef with a TCG_TARGET_HAS_direct_jump
boolean test.  Replace the tb_set_jmp_target1 ifdef with an unconditional
function tb_target_set_jmp_target.

While we're touching all backends, add a parameter for tb->tc_ptr;
we're going to need it shortly for some backends.

Move tb_set_jmp_target and tb_add_jump from exec-all.h to cpu-exec.c.

This opens the possibility for TCG_TARGET_HAS_direct_jump to be
a runtime decision -- based on host cpu capabilities, the size of
code_gen_buffer, or a future debugging switch.

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/hppa: Convert to TranslatorOps
Richard Henderson [Sat, 15 Jul 2017 08:25:35 +0000 (22:25 -1000)]
target/hppa: Convert to TranslatorOps

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/hppa: Convert to DisasContextBase
Richard Henderson [Sat, 15 Jul 2017 07:00:32 +0000 (21:00 -1000)]
target/hppa: Convert to DisasContextBase

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/hppa: Convert to DisasJumpType
Richard Henderson [Sat, 15 Jul 2017 06:56:35 +0000 (20:56 -1000)]
target/hppa: Convert to DisasJumpType

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/alpha: Switch to do_transaction_failed() hook
Peter Maydell [Tue, 8 Aug 2017 12:42:52 +0000 (13:42 +0100)]
target/alpha: Switch to do_transaction_failed() hook

Switch the alpha target from the old unassigned_access hook
to the new do_transaction_failed hook. This allows us to
resolve a ??? in the old hook implementation.

The only part of the alpha target that does physical
memory accesses is reading the page table -- add a
TODO comment there to the effect that we should handle
bus faults on page table walks. (Since the palcode
doesn't actually do anything useful on a bus fault anyway
it's a bit moot for now.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <1502196172-13818-1-git-send-email-peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6 years agotarget/alpha: Convert to TranslatorOps
Richard Henderson [Fri, 14 Jul 2017 23:47:59 +0000 (13:47 -1000)]
target/alpha: Convert to TranslatorOps

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/alpha: Convert to DisasContextBase
Richard Henderson [Fri, 14 Jul 2017 23:32:08 +0000 (13:32 -1000)]
target/alpha: Convert to DisasContextBase

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agotarget/alpha: Convert to DisasJumpType
Richard Henderson [Fri, 14 Jul 2017 23:17:03 +0000 (13:17 -1000)]
target/alpha: Convert to DisasJumpType

Signed-off-by: Richard Henderson <rth@twiddle.net>
6 years agoconfigure: Drop AIX host support
Peter Maydell [Mon, 4 Sep 2017 17:19:00 +0000 (18:19 +0100)]
configure: Drop AIX host support

Nobody has mentioned AIX host support on the mailing list for years,
and we have no test systems for it so it is most likely broken.
We've advertised in configure for two releases now that we plan
to drop support for this host OS, and have had no complaints.
Drop the AIX host support code.

We can also drop the now-unused AIX version of sys_cache_info().

Note that the _CALL_AIX define used in the PPC tcg backend is
also used for Linux PPC64, and so that code should not be removed.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1504545540-8002-1-git-send-email-peter.maydell@linaro.org

6 years agotcg/tci: Add TCG_TARGET_DEFAULT_MO
Richard Henderson [Thu, 7 Sep 2017 17:54:30 +0000 (10:54 -0700)]
tcg/tci: Add TCG_TARGET_DEFAULT_MO

Missed being added as part of 71650df7b0ee.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-09-06' into staging
Peter Maydell [Thu, 7 Sep 2017 16:53:59 +0000 (17:53 +0100)]
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-09-06' into staging

nbd patches for 2017-09-06

- Daniel P. Berrange: [0/2] Fix / skip recent iotests with LUKS driver
- Eric Blake: [0/3] nbd: Use common read/write-all qio functions

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

* remotes/ericb/tags/pull-nbd-2017-09-06:
  nbd: Use new qio_channel_*_all() functions
  io: Add new qio_channel_read{, v}_all_eof functions
  io: Yield rather than wait when already in coroutine
  iotests: blacklist 194 with the luks driver
  iotests: rewrite 192 to use _launch_qemu to fix LUKS support

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170907' into...
Peter Maydell [Thu, 7 Sep 2017 15:42:55 +0000 (16:42 +0100)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170907' into staging

target-arm:
 * cleanups converting to DEFINE_PROP_LINK
 * allwinner-a10: mark as not user-creatable
 * initial patches working towards ARMv8M support
 * implement generating aborts on memory transaction failures
 * make BXJ behave correctly (ie not UNDEF) on ARMv6-and-later

# gpg: Signature made Thu 07 Sep 2017 14:26:07 BST
# gpg:                using RSA key 0x3C2525ED14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>"
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20170907: (31 commits)
  target/arm: Add Jazelle feature
  target/arm: Implement new do_transaction_failed hook
  hw/arm: Set ignore_memory_transaction_failures for most ARM boards
  boards.h: Define new flag ignore_memory_transaction_failures
  target/arm: Implement BXNS, and banked stack pointers
  target/arm: Move regime_is_secure() to target/arm/internals.h
  target/arm: Make CFSR register banked for v8M
  target/arm: Make MMFAR banked for v8M
  target/arm: Make CCR register banked for v8M
  target/arm: Make MPU_CTRL register banked for v8M
  target/arm: Make MPU_RNR register banked for v8M
  target/arm: Make MPU_RBAR, MPU_RLAR banked for v8M
  target/arm: Make MPU_MAIR0, MPU_MAIR1 registers banked for v8M
  target/arm: Make VTOR register banked for v8M
  nvic: Add NS alias SCS region
  target/arm: Make CONTROL register banked for v8M
  target/arm: Make FAULTMASK register banked for v8M
  target/arm: Make PRIMASK register banked for v8M
  target/arm: Make BASEPRI register banked for v8M
  target/arm: Add MMU indexes for secure v8M
  ...

# Conflicts:
# target/arm/translate.c

6 years agoMerge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20170906a' into...
Peter Maydell [Thu, 7 Sep 2017 14:26:06 +0000 (15:26 +0100)]
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20170906a' into staging

migration pull 2017-09-06

# gpg: Signature made Wed 06 Sep 2017 19:39:23 BST
# gpg:                using RSA key 0x0516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20170906a:
  migration: dump str in migrate_set_state trace
  snapshot/tests: Try loadvm twice
  migration: Reset rather than destroy main_thread_load_event
  runstate/migrate: Two more transitions
  host-utils: Simplify pow2ceil()
  host-utils: Proactively fix pow2floor(), switch to unsigned
  xbzrle: Drop unused cache_resize()
  migration: Report when bdrv_inactivate_all fails

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tgt-20170906' into staging
Peter Maydell [Thu, 7 Sep 2017 13:34:25 +0000 (14:34 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tgt-20170906' into staging

tcg generic translate loop v15

# gpg: Signature made Wed 06 Sep 2017 17:02:31 BST
# gpg:                using RSA key 0x64DF38E8AF7E215F
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-tgt-20170906: (32 commits)
  target/arm: Perform per-insn cross-page check only for Thumb
  target/arm: Split out thumb_tr_translate_insn
  target/arm: Move ss check to init_disas_context
  target/arm: [a64] Move page and ss checks to init_disas_context
  target/arm: [tcg] Port to generic translation framework
  target/arm: [tcg,a64] Port to disas_log
  target/arm: [tcg] Port to disas_log
  target/arm: [tcg,a64] Port to tb_stop
  target/arm: [tcg] Port to tb_stop
  target/arm: [tcg,a64] Port to translate_insn
  target/arm: [tcg] Port to translate_insn
  target/arm: [tcg,a64] Port to breakpoint_check
  target/arm: [tcg,a64] Port to insn_start
  target/arm: [tcg] Port to insn_start
  target/arm: [tcg] Port to tb_start
  target/arm: [tcg,a64] Port to init_disas_context
  target/arm: [tcg] Port to init_disas_context
  target/arm: [tcg] Port to DisasContextBase
  target/i386: [tcg] Port to generic translation framework
  target/i386: [tcg] Port to disas_log
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agotarget/arm: Add Jazelle feature
Portia Stephens [Thu, 7 Sep 2017 12:54:55 +0000 (13:54 +0100)]
target/arm: Add Jazelle feature

This adds a feature bit indicating support of the (trivial) Jazelle
implementation if ARM_FEATURE_V6 is set or if the processor is arm926
or arm1026.  This fixes the issue that any BXJ instruction will
result in an illegal_op.  BXJ instructions will now check if the
architecture supports ARM_FEATURE_JAZELLE.

Signed-off-by: Portia Stephens <portia.stephens@xilinx.com>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
Message-id: 20170905211232.11092-1-portia.stephens@xilinx.com
[PMM: edited commit message and comment text a bit]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>