]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
7 years agotcg/i386: Handle ctpop opcode
Richard Henderson [Tue, 22 Nov 2016 13:15:04 +0000 (14:15 +0100)]
tcg/i386: Handle ctpop opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/ppc: Handle ctpop opcode
Richard Henderson [Tue, 22 Nov 2016 11:43:12 +0000 (11:43 +0000)]
tcg/ppc: Handle ctpop opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Use ctpop to generate ctz if needed
Richard Henderson [Tue, 22 Nov 2016 12:40:35 +0000 (12:40 +0000)]
tcg: Use ctpop to generate ctz if needed

Particularly when andc is also available, this is two insns
shorter than using clz to compute ctz.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotests: New test-bitcnt
Alex Bennée [Fri, 9 Dec 2016 14:36:00 +0000 (14:36 +0000)]
tests: New test-bitcnt

Add some unit tests for bit count functions (currently only ctpop). As
the routines are based on the Hackers Delight optimisations I based
the test patterns on their tests.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agoqemu/host-utils.h: Reduce the operation count in the fallback ctpop
Richard Henderson [Mon, 21 Nov 2016 11:30:34 +0000 (12:30 +0100)]
qemu/host-utils.h: Reduce the operation count in the fallback ctpop

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-i386: Use ctpop helper
Richard Henderson [Mon, 21 Nov 2016 11:18:53 +0000 (12:18 +0100)]
target-i386: Use ctpop helper

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-tilegx: Use ctpop helper
Richard Henderson [Mon, 21 Nov 2016 11:10:28 +0000 (12:10 +0100)]
target-tilegx: Use ctpop helper

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-sparc: Use ctpop helper
Richard Henderson [Mon, 21 Nov 2016 11:08:27 +0000 (12:08 +0100)]
target-sparc: Use ctpop helper

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-s390x: Avoid a loop for popcnt
Richard Henderson [Mon, 21 Nov 2016 11:06:26 +0000 (12:06 +0100)]
target-s390x: Avoid a loop for popcnt

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-ppc: Use ctpop helper
Richard Henderson [Mon, 21 Nov 2016 10:58:25 +0000 (11:58 +0100)]
target-ppc: Use ctpop helper

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-alpha: Use ctpop helper
Richard Henderson [Mon, 21 Nov 2016 10:48:24 +0000 (11:48 +0100)]
target-alpha: Use ctpop helper

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Add opcode for ctpop
Richard Henderson [Mon, 21 Nov 2016 10:13:39 +0000 (11:13 +0100)]
tcg: Add opcode for ctpop

The number of actual invocations of ctpop itself does not warrent
an opcode, but it is very helpful for POWER7 to use in generating
an expansion for ctz.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-xtensa: Use clrsb helper
Richard Henderson [Wed, 16 Nov 2016 16:38:10 +0000 (17:38 +0100)]
target-xtensa: Use clrsb helper

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-tricore: Use clrsb helper
Richard Henderson [Wed, 16 Nov 2016 16:36:51 +0000 (17:36 +0100)]
target-tricore: Use clrsb helper

Tested-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-arm: Use clrsb helper
Richard Henderson [Wed, 16 Nov 2016 16:35:35 +0000 (17:35 +0100)]
target-arm: Use clrsb helper

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Add helpers for clrsb
Richard Henderson [Wed, 16 Nov 2016 16:32:48 +0000 (17:32 +0100)]
tcg: Add helpers for clrsb

The number of actual invocations does not warrent an opcode,
and the backends generating it.  But at least we can eliminate
redundant helpers.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/i386: Rely on undefined/undocumented behaviour of BSF/BSR
Richard Henderson [Fri, 18 Nov 2016 16:02:59 +0000 (17:02 +0100)]
tcg/i386: Rely on undefined/undocumented behaviour of BSF/BSR

The ISA manual documents the output is undefined if the input was zero.

However, we document in target-i386 that the behavior of real silicon
is to preserve the contents of the output register.  We also mention
that there are real applications that depend on this.  That this is
baked into silicon is mentioned as a potential cause for some false
sharing behaviour wrt lzcnt/tzcnt.

Taking advantage of this allows us to save 2 insns in the normal case,
and 4 insns for i686 emulating a 64-bit clz.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/i386: Handle ctz and clz opcodes
Richard Henderson [Wed, 16 Nov 2016 11:22:54 +0000 (12:22 +0100)]
tcg/i386: Handle ctz and clz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/i386: Allow bmi2 shiftx to have non-matching operands
Richard Henderson [Fri, 18 Nov 2016 13:18:41 +0000 (14:18 +0100)]
tcg/i386: Allow bmi2 shiftx to have non-matching operands

Previously we could not have different constraints for different ISA levels,
which prevented us from eliding the matching constraint for shifts.

We do now have to make sure that the operands match for constant shifts.
We can also handle some small left shifts via lea.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/i386: Hoist common arguments in tcg_out_op
Richard Henderson [Fri, 18 Nov 2016 11:50:50 +0000 (12:50 +0100)]
tcg/i386: Hoist common arguments in tcg_out_op

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/i386: Fuly convert tcg_target_op_def
Richard Henderson [Fri, 18 Nov 2016 10:55:41 +0000 (11:55 +0100)]
tcg/i386: Fuly convert tcg_target_op_def

Use a switch instead of searching a table.  Share constraints between
32-bit and 64-bit, when at all possible.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/s390: Handle clz opcode
Richard Henderson [Wed, 16 Nov 2016 15:10:37 +0000 (16:10 +0100)]
tcg/s390: Handle clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/mips: Handle clz opcode
Richard Henderson [Wed, 16 Nov 2016 14:34:03 +0000 (15:34 +0100)]
tcg/mips: Handle clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/arm: Handle ctz and clz opcodes
Richard Henderson [Wed, 16 Nov 2016 13:59:40 +0000 (14:59 +0100)]
tcg/arm: Handle ctz and clz opcodes

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/aarch64: Handle ctz and clz opcodes
Richard Henderson [Wed, 16 Nov 2016 13:03:28 +0000 (14:03 +0100)]
tcg/aarch64: Handle ctz and clz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/ppc: Handle ctz and clz opcodes
Richard Henderson [Wed, 16 Nov 2016 11:48:55 +0000 (12:48 +0100)]
tcg/ppc: Handle ctz and clz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-i386: Use clz and ctz opcodes
Richard Henderson [Wed, 16 Nov 2016 11:21:13 +0000 (12:21 +0100)]
target-i386: Use clz and ctz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-arm: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 10:49:06 +0000 (11:49 +0100)]
target-arm: Use clz opcode

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-xtensa: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 10:48:37 +0000 (11:48 +0100)]
target-xtensa: Use clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-unicore32: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 10:40:39 +0000 (11:40 +0100)]
target-unicore32: Use clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-tricore: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 10:37:15 +0000 (11:37 +0100)]
target-tricore: Use clz opcode

Tested-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Reviewed-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-tilegx: Use clz and ctz opcodes
Richard Henderson [Wed, 16 Nov 2016 10:33:48 +0000 (11:33 +0100)]
target-tilegx: Use clz and ctz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-s390x: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 10:30:34 +0000 (11:30 +0100)]
target-s390x: Use clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-ppc: Use clz and ctz opcodes
Richard Henderson [Wed, 16 Nov 2016 10:27:03 +0000 (11:27 +0100)]
target-ppc: Use clz and ctz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-openrisc: Use clz and ctz opcodes
Richard Henderson [Wed, 16 Nov 2016 10:17:45 +0000 (11:17 +0100)]
target-openrisc: Use clz and ctz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-mips: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 10:11:54 +0000 (11:11 +0100)]
target-mips: Use clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-microblaze: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 09:58:52 +0000 (10:58 +0100)]
target-microblaze: Use clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-cris: Use clz opcode
Richard Henderson [Wed, 16 Nov 2016 09:54:57 +0000 (10:54 +0100)]
target-cris: Use clz opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-alpha: Use the ctz and clz opcodes
Richard Henderson [Wed, 16 Nov 2016 09:23:30 +0000 (10:23 +0100)]
target-alpha: Use the ctz and clz opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agodisas/ppc: Handle popcnt and cnttz
Richard Henderson [Tue, 22 Nov 2016 12:38:46 +0000 (12:38 +0000)]
disas/ppc: Handle popcnt and cnttz

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agodisas/i386.c: Handle tzcnt
Richard Henderson [Wed, 16 Nov 2016 11:22:15 +0000 (12:22 +0100)]
disas/i386.c: Handle tzcnt

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Add clz and ctz opcodes
Richard Henderson [Wed, 16 Nov 2016 08:23:28 +0000 (09:23 +0100)]
tcg: Add clz and ctz opcodes

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Allow an operand to be matching or a constant
Richard Henderson [Fri, 18 Nov 2016 16:41:24 +0000 (17:41 +0100)]
tcg: Allow an operand to be matching or a constant

This allows an output operand to match an input operand
only when the input operand needs a register.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Pass the opcode width to target_parse_constraint
Richard Henderson [Fri, 18 Nov 2016 10:50:59 +0000 (11:50 +0100)]
tcg: Pass the opcode width to target_parse_constraint

This will let us choose how to interpret a given constraint
depending on whether the opcode is 32- or 64-bit.  Which will
let us share more constraint combinations between opcodes.

At the same time, change the interface to return the advanced
pointer instead of passing it in/out by reference.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Transition flat op_defs array to a target callback
Richard Henderson [Fri, 18 Nov 2016 08:31:40 +0000 (09:31 +0100)]
tcg: Transition flat op_defs array to a target callback

This will allow the target to tailor the constraints to the
auto-detected ISA extensions.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Add markup for output requires new register
Richard Henderson [Fri, 18 Nov 2016 07:35:03 +0000 (08:35 +0100)]
tcg: Add markup for output requires new register

This is the same concept as, and same markup as, the
early clobber markup in gcc.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/optimize: Fold movcond 0/1 into setcond
Richard Henderson [Mon, 24 Oct 2016 03:44:32 +0000 (20:44 -0700)]
tcg/optimize: Fold movcond 0/1 into setcond

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-s390x: Use the new deposit and extract ops
Richard Henderson [Mon, 17 Oct 2016 21:50:31 +0000 (14:50 -0700)]
target-s390x: Use the new deposit and extract ops

Use the new primitives for RISBG.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-ppc: Use the new deposit and extract ops
Richard Henderson [Sat, 15 Oct 2016 18:37:19 +0000 (13:37 -0500)]
target-ppc: Use the new deposit and extract ops

Use the new primitives for RDWINM and RLDICL.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-mips: Use the new extract op
Richard Henderson [Sat, 15 Oct 2016 17:04:13 +0000 (12:04 -0500)]
target-mips: Use the new extract op

Use extract for EXT and DEXT.

Reviewed-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-i386: Use new deposit and extract ops
Richard Henderson [Sat, 15 Oct 2016 16:54:17 +0000 (11:54 -0500)]
target-i386: Use new deposit and extract ops

A couple of places where it was easy to identify a right-shift
followed by an extract or and-with-immediate, and the obvious
sign-extract from a high byte register.

Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-arm: Use new deposit and extract ops
Richard Henderson [Sat, 15 Oct 2016 16:41:29 +0000 (11:41 -0500)]
target-arm: Use new deposit and extract ops

Use the new primitives for UBFX and SBFX.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-alpha: Use deposit and extract ops
Richard Henderson [Fri, 14 Oct 2016 22:35:42 +0000 (17:35 -0500)]
target-alpha: Use deposit and extract ops

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/s390: Support deposit into zero
Richard Henderson [Tue, 18 Oct 2016 00:00:46 +0000 (17:00 -0700)]
tcg/s390: Support deposit into zero

Since we can no longer use matching constraints, this does
mean we must handle that data movement by hand.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/s390: Implement field extraction opcodes
Richard Henderson [Fri, 14 Oct 2016 19:26:40 +0000 (14:26 -0500)]
tcg/s390: Implement field extraction opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/s390: Expose host facilities to tcg-target.h
Richard Henderson [Mon, 17 Oct 2016 15:24:38 +0000 (11:24 -0400)]
tcg/s390: Expose host facilities to tcg-target.h

This lets us expose facilities to TCG_TARGET_HAS_* defines
directly, rather than hiding behind function calls.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/ppc: Implement field extraction opcodes
Richard Henderson [Fri, 14 Oct 2016 19:18:03 +0000 (14:18 -0500)]
tcg/ppc: Implement field extraction opcodes

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/mips: Implement field extraction opcodes
Richard Henderson [Fri, 14 Oct 2016 20:50:25 +0000 (15:50 -0500)]
tcg/mips: Implement field extraction opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/i386: Implement field extraction opcodes
Richard Henderson [Fri, 14 Oct 2016 19:08:13 +0000 (14:08 -0500)]
tcg/i386: Implement field extraction opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/arm: Implement field extraction opcodes
Richard Henderson [Sat, 15 Oct 2016 00:51:45 +0000 (19:51 -0500)]
tcg/arm: Implement field extraction opcodes

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/arm: Move isa detection to tcg-target.h
Richard Henderson [Sat, 15 Oct 2016 00:45:26 +0000 (19:45 -0500)]
tcg/arm: Move isa detection to tcg-target.h

This allows us to use this detection within the TCG_TARGET_HAS_*
macros, instead of requiring a function call into tcg-target.inc.c.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg/aarch64: Implement field extraction opcodes
Richard Henderson [Fri, 14 Oct 2016 18:20:49 +0000 (13:20 -0500)]
tcg/aarch64: Implement field extraction opcodes

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Add deposit_z expander
Richard Henderson [Mon, 17 Oct 2016 20:21:31 +0000 (13:21 -0700)]
tcg: Add deposit_z expander

While we don't require a new opcode, it is handy to have an expander
that knows the first source is zero.

Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Minor adjustments to deposit expanders
Richard Henderson [Fri, 14 Oct 2016 22:26:38 +0000 (17:26 -0500)]
tcg: Minor adjustments to deposit expanders

Assert that len is not 0.

Since we have asserted that ofs + len <= N, a later
check for len == N implies that ofs == 0.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Add field extraction primitives
Richard Henderson [Fri, 14 Oct 2016 17:04:32 +0000 (12:04 -0500)]
tcg: Add field extraction primitives

Adds tcg_gen_extract_* and tcg_gen_sextract_* for extraction of
fixed position bitfields, much like we already have for deposit.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
7 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Peter Maydell [Tue, 10 Jan 2017 10:46:21 +0000 (10:46 +0000)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

virtio, vhost, pc: fixes, features

beginnings of iotlb support for vhost
acpi hotplug rework
vhost net tx flush on link down
passing mtu to guests
hotplug for virtio crypto
fixes and cleanups all over the place

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Tue 10 Jan 2017 05:37:48 GMT
# gpg:                using RSA key 0x281F0DB8D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream: (41 commits)
  acpi-test: update expected files
  memhp: move DIMM devices into dedicated scope with related common methods
  memhp: don't generate memory hotplug AML if it's not enabled/supported
  memhp: move memory hotplug only defines to memory_hotplug.c
  memhp: move GPE handler_E03 into build_memory_hotplug_aml()
  memhp: merge build_memory_devices() into build_memory_hotplug_aml()
  memhp: consolidate scattered MHPD device declaration
  memhp: move build_memory_devices() into memory_hotplug.c
  memhp: move build_memory_hotplug_aml() into memory_hotplug.c
  tests: pc: add memory hotplug acpi tables tests
  virtio-net: Add MTU feature support
  vhost-net: Notify the backend about the host MTU
  vhost-user: Add MTU protocol feature and op
  net: virtio-net discards TX data after link down
  virtio: Introduce virtqueue_drop_all procedure
  net: vhost stop updates virtio queue state
  net: Add virtio queue interface to update used index from vring state
  balloon: Don't balloon roms
  virtio: fix vq->inuse recalc after migr
  pcie_aer: support configurable AER capa version
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoacpi-test: update expected files
Michael S. Tsirkin [Tue, 10 Jan 2017 05:06:42 +0000 (07:06 +0200)]
acpi-test: update expected files

clean up warnings after latest hotplug changes.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agomemhp: move DIMM devices into dedicated scope with related common methods
Igor Mammedov [Mon, 5 Dec 2016 23:32:29 +0000 (00:32 +0100)]
memhp: move DIMM devices into dedicated scope with related common methods

Move DIMM devices from global _SB scope to a new \_SB.MHPC
container along with common methods used by DIMMs:
  MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY

this reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agomemhp: don't generate memory hotplug AML if it's not enabled/supported
Igor Mammedov [Mon, 5 Dec 2016 23:32:28 +0000 (00:32 +0100)]
memhp: don't generate memory hotplug AML if it's not enabled/supported

That reduces DSDT by 910 bytes when memory hotplug
isn't enabled.

While doing so drop intermediate variables/arguments
passing around ACPI_MEMORY_HOTPLUG_IO_LEN and making
it local to memory_hotplug.c, hardcoding it there as
it can't change.

Also don't pass around ACPI_MEMORY_HOTPLUG_BASE through
intermediate variables/arguments where it's not needed.
Instead initialize in module static variable when MMIO
region is mapped and use that within memory_hotplug.c
whenever it's required.
That way MMIO base specified only at one place and AML
with MMIO would always use the same value.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agomemhp: move memory hotplug only defines to memory_hotplug.c
Igor Mammedov [Mon, 5 Dec 2016 23:32:27 +0000 (00:32 +0100)]
memhp: move memory hotplug only defines to memory_hotplug.c

Move defines used locally only by memory_hotplug.c into it
from header files.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agomemhp: move GPE handler_E03 into build_memory_hotplug_aml()
Igor Mammedov [Mon, 5 Dec 2016 23:32:26 +0000 (00:32 +0100)]
memhp: move GPE handler_E03 into build_memory_hotplug_aml()

>From this patch all the memory hotplug related AML
bits are consolidated in one place within DSTD.
Follow up patches will utilize that to simplify
memory hotplug related C/AML code.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agomemhp: merge build_memory_devices() into build_memory_hotplug_aml()
Igor Mammedov [Mon, 5 Dec 2016 23:32:25 +0000 (00:32 +0100)]
memhp: merge build_memory_devices() into build_memory_hotplug_aml()

It consolidates memory hotplug AML in one place within DSDT

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agomemhp: consolidate scattered MHPD device declaration
Igor Mammedov [Mon, 5 Dec 2016 23:32:24 +0000 (00:32 +0100)]
memhp: consolidate scattered MHPD device declaration

since static and dynamic parts of memory MHPD device are now
in the same table (DSDT), there is no point keeping
them scattered across the table, so consolidate it
in one place.

There aren't any functional change, only AML text movement
from externally refferenced MHPD scope directly into
MHPD device declaration.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agomemhp: move build_memory_devices() into memory_hotplug.c
Igor Mammedov [Mon, 5 Dec 2016 23:32:23 +0000 (00:32 +0100)]
memhp: move build_memory_devices() into memory_hotplug.c

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agomemhp: move build_memory_hotplug_aml() into memory_hotplug.c
Igor Mammedov [Mon, 5 Dec 2016 23:32:22 +0000 (00:32 +0100)]
memhp: move build_memory_hotplug_aml() into memory_hotplug.c

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agotests: pc: add memory hotplug acpi tables tests
Igor Mammedov [Mon, 5 Dec 2016 23:32:20 +0000 (00:32 +0100)]
tests: pc: add memory hotplug acpi tables tests

This also adds SRAT and DSDT blobs for memory hotplug variant

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
7 years agovirtio-net: Add MTU feature support
Maxime Coquelin [Sat, 10 Dec 2016 15:30:38 +0000 (16:30 +0100)]
virtio-net: Add MTU feature support

This patch allows advising guest with host MTU's by setting
host_mtu parameter.

If VIRTIO_NET_F_MTU has been successfully negotiated, MTU
value is passed to the backend.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Aaron Conole <aconole@redhat.com
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovhost-net: Notify the backend about the host MTU
Maxime Coquelin [Sat, 10 Dec 2016 15:30:37 +0000 (16:30 +0100)]
vhost-net: Notify the backend about the host MTU

This patch provides a way for virtio-net to notify the
backend about the host MTU set by the user.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Aaron Conole <aconole@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovhost-user: Add MTU protocol feature and op
Maxime Coquelin [Sat, 10 Dec 2016 15:30:36 +0000 (16:30 +0100)]
vhost-user: Add MTU protocol feature and op

This patch implements VHOST_USER_PROTOCOL_F_NET_MTU
protocol feature and VHOST_USER_NET_SET_MTU request so
that the backend gets notified of the user defined host
MTU.

If backend supports VHOST_USER_PROTOCOL_F_REPLY_ACK,
QEMU assumes MTU is valid if success is returned.

Vhost-net driver sends this request through a new
vhost_net_set_mtu vhost_ops entry.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Aaron Conole <aconole@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agonet: virtio-net discards TX data after link down
Yuri Benditovich [Tue, 13 Dec 2016 08:12:08 +0000 (10:12 +0200)]
net: virtio-net discards TX data after link down

https://bugzilla.redhat.com/show_bug.cgi?id=1295637
Upon set_link monitor command or upon netdev deletion
virtio-net sends link down indication to the guest
and stops vhost if one is used.
Guest driver can still submit data for TX until it
recognizes link loss. If these packets not returned by
the host, the Windows guest will never be able to finish
disable/removal/shutdown.
Now each packet sent by guest after NIC indicated link
down will be completed immediately.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio: Introduce virtqueue_drop_all procedure
Yuri Benditovich [Tue, 13 Dec 2016 08:12:07 +0000 (10:12 +0200)]
virtio: Introduce virtqueue_drop_all procedure

Add procedure for fast drop of queued packets, acting like
pop and push without mapping the buffers into memory.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agonet: vhost stop updates virtio queue state
Yuri Benditovich [Tue, 13 Dec 2016 08:12:06 +0000 (10:12 +0200)]
net: vhost stop updates virtio queue state

Make virtio queue suitable for push operation from qemu
after vhost was stopped.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agonet: Add virtio queue interface to update used index from vring state
Yuri Benditovich [Tue, 13 Dec 2016 08:12:05 +0000 (10:12 +0200)]
net: Add virtio queue interface to update used index from vring state

Bring virtio queue to correct internal  state for host-to-guest
operations when vhost is temporary stopped.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agoballoon: Don't balloon roms
Dr. David Alan Gilbert [Fri, 16 Dec 2016 11:41:55 +0000 (11:41 +0000)]
balloon: Don't balloon roms

A broken guest can specify physical addresses that correspond
to any memory region, but it shouldn't be able to change ROM.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: qemu-stable@nongnu.org
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio: fix vq->inuse recalc after migr
Halil Pasic [Mon, 19 Dec 2016 15:44:44 +0000 (16:44 +0100)]
virtio: fix vq->inuse recalc after migr

Correct recalculation of vq->inuse after migration for the corner case
where the avail_idx has already wrapped but used_idx not yet.

Also change the type of the VirtQueue.inuse to unsigned int. This is
done to be consistent with other members representing sizes (VRing.num),
and because C99 guarantees max ring size < UINT_MAX but does not
guarantee max ring size < INT_MAX.

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Fixes: bccdef6b ("virtio: recalculate vq->inuse after migration")
CC: qemu-stable@nongnu.org
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7 years agopcie_aer: support configurable AER capa version
Dou Liyang [Wed, 21 Dec 2016 08:21:31 +0000 (16:21 +0800)]
pcie_aer: support configurable AER capa version

Now, AER capa version is fixed to v2, if assigned device isn't v2,
then this value will be inconsistent between guest and host

Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agopcie_aer: Convert pcie_aer_init to Error
Cao jin [Wed, 21 Dec 2016 08:21:30 +0000 (16:21 +0800)]
pcie_aer: Convert pcie_aer_init to Error

When user specify invalid value for property aer_log_max, device should
fail to create, and report appropriate message.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Acked-by: Dmitry Fleytman <dmitry@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio-crypto: zeroize the key material before free
Gonglei [Thu, 22 Dec 2016 03:01:28 +0000 (11:01 +0800)]
virtio-crypto: zeroize the key material before free

Common practice with sensitive information (key material, passwords,
etc). Prevents sensitive information from being exposed by accident later in
coredumps, memory disclosure bugs when heap memory is reused, etc.

Sensitive information is sometimes also held in mlocked pages to prevent
it being swapped to disk but that's not being done here.

Let's zeroize the memory of CryptoDevBackendSymOpInfo structure pointed
for key material security.

[Thanks to Stefan for help with crafting the commit message]

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio-crypto-pci: tag virtio-crypto device hot pluggable
Gonglei [Thu, 22 Dec 2016 03:12:42 +0000 (11:12 +0800)]
virtio-crypto-pci: tag virtio-crypto device hot pluggable

After resolving the relationship with cryptodev backend,
the virtio crypto device supports hotplug now.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio-crypto: avoid one cryptodev device is used by multiple virtio crypto devices
Gonglei [Thu, 22 Dec 2016 03:12:41 +0000 (11:12 +0800)]
virtio-crypto: avoid one cryptodev device is used by multiple virtio crypto devices

Add the check condition for cryptodev device in order
to avoid one cryptodev device is used by multiple
virtio crypto devices.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio-crypto-pci: add check for cryptodev object
Gonglei [Thu, 22 Dec 2016 03:12:40 +0000 (11:12 +0800)]
virtio-crypto-pci: add check for cryptodev object

We must assure each virtio crypto pci device has
an vaild cryptodev backend object.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agocryptodev: wrap the ready flag
Gonglei [Thu, 22 Dec 2016 03:12:39 +0000 (11:12 +0800)]
cryptodev: wrap the ready flag

The ready flag should be set by the children of
cryptodev backend interface. Warp the setter/getter
functions for it.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agocryptodev: introduce a new is_used property
Gonglei [Thu, 22 Dec 2016 03:12:38 +0000 (11:12 +0800)]
cryptodev: introduce a new is_used property

This property is used to Tag the cryptodev backend
is used by virtio-crypto or not. Making cryptodev
can't be hot unplugged when it's in use. Cleanup
resources when cryptodev is finalized.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio-crypto: use the correct length for cipher operation
Gonglei [Thu, 22 Dec 2016 03:37:03 +0000 (11:37 +0800)]
virtio-crypto: use the correct length for cipher operation

In some modes of cipher algorithms, the length of destination data
maybe larger then source data, such as ciphertext stealing (CTS).

For symmetric algorithms, the length of ciphertext is definitly
equal to the plaintext for each crypto operation. So we should
use the src_len instead of dst_len avoid to pass the incorrect
cryptographical results to the frontend driver.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agodoc/pcie: correct command line examples
Cao jin [Thu, 29 Dec 2016 01:19:37 +0000 (09:19 +0800)]
doc/pcie: correct command line examples

Nit picking: Multi-function PCI Express Root Ports should mean that
'addr' property is mandatory, and slot is optional because it defaults
to 0, and 'chassis' is mandatory for 2nd & 3rd root port because it
defaults to 0 too.

Bonus: fix a typo(2->3)
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agomemory: handle alias in memory_region_is_iommu()
Jason Wang [Fri, 30 Dec 2016 10:09:18 +0000 (18:09 +0800)]
memory: handle alias in memory_region_is_iommu()

Cc: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agomemory: handle alias for iommu notifier
Jason Wang [Fri, 30 Dec 2016 10:09:17 +0000 (18:09 +0800)]
memory: handle alias for iommu notifier

Cc: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoacpi: add ATSR for q35
Jason Wang [Fri, 30 Dec 2016 10:09:16 +0000 (18:09 +0800)]
acpi: add ATSR for q35

This patch provides ATSR which was a requirement for software that
wants to enable ATS on endpoint devices behind a Root Port. This is
done simply by setting ALL_PORTS which indicates all PCI-Express Root
Ports support ATS transactions.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agovirtio-pci: address space translation service (ATS) support
Jason Wang [Fri, 30 Dec 2016 10:09:15 +0000 (18:09 +0800)]
virtio-pci: address space translation service (ATS) support

This patches enable the Address Translation Service support for virtio
pci devices. This is needed for a guest visible Device IOTLB
implementation and will be required by vhost device IOTLB API
implementation for intel IOMMU.

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7 years agointel_iommu: support device iotlb descriptor
Jason Wang [Fri, 30 Dec 2016 10:09:14 +0000 (18:09 +0800)]
intel_iommu: support device iotlb descriptor

This patch enables device IOTLB support for intel iommu. The major
work is to implement QI device IOTLB descriptor processing and notify
the device through iommu notifier.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>