sdk/emulator/qemu.git
10 years agoMerge remote-tracking branch 'remotes/rth/tags/tcg-next-20140422' into staging
Peter Maydell [Thu, 24 Apr 2014 14:24:51 +0000 (15:24 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/tcg-next-20140422' into staging

Pull tcg 2014-04-22

# gpg: Signature made Tue 22 Apr 2014 22:00:04 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/tcg-next-20140422:
  tcg: Use HOST_WORDS_BIGENDIAN
  tcg: Fix fallback from muls2_i64 to mulu2_i64
  tcg: Use tcg_gen_mulu2_i32 in tcg_gen_muls2_i32
  tcg: Relax requirement for mulu2_i32 on 32-bit hosts
  tcg-s390: Remove W constraint
  tcg-sparc: Use the type parameter to tcg_target_const_match
  tcg-ppc64: Use the type parameter to tcg_target_const_match
  tcg-aarch64: Remove w constraint
  tcg: Add TCGType parameter to tcg_target_const_match
  tcg: Fix out of range shift in deposit optimizations
  tci: Mask shift counts to avoid undefined behavior
  tcg: Mask shift quantities while folding
  tcg: Use "unspecified behavior" for shifts
  tcg: Fix warning (1 bit signed bitfield entry) and replace int by bool

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/rth/tags/tcg-ia64-pull-20140421' into staging
Peter Maydell [Thu, 24 Apr 2014 13:14:51 +0000 (14:14 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/tcg-ia64-pull-20140421' into staging

Pull for 20140421

# gpg: Signature made Mon 21 Apr 2014 17:57:24 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/tcg-ia64-pull-20140421:
  tcg-ia64: Convert to new ldst opcodes
  tcg-ia64: Move part of softmmu slow path out of line
  tcg-ia64: Convert to new ldst helpers
  tcg-ia64: Reduce code duplication in tcg_out_qemu_ld
  tcg-ia64: Move tlb addend load into tlb read
  tcg-ia64: Move bswap for store into tlb load
  tcg-ia64: Re-bundle the tlb load
  tcg-ia64: Optimize small arguments to exit_tb

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-04-18' into staging
Peter Maydell [Thu, 24 Apr 2014 12:22:16 +0000 (13:22 +0100)]
Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-04-18' into staging

trivial patches for 2014-04-18

# gpg: Signature made Fri 18 Apr 2014 07:36:15 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514  66A7 BEE5 9D74 A4C3 D7DB

* remotes/mjt/tags/trivial-patches-2014-04-18:
  Fix grammar in comment
  doc: grammify "allows to"
  configure: Remove redundant message for -Werror
  scripts: add sample model file for Coverity Scan
  xbzrle.c: Avoid undefined behaviour with signed arithmetic
  int128.h: Avoid undefined behaviours involving signed arithmetic
  hw/ide/ahci.c: Avoid shift left into sign bit
  net: Report error when device / hub combo is not found.
  configure: Fix indentation of help for --enable/disable-debug-info
  qga: trivial fix for unclear documentation of guest-set-time
  vl: Report accelerator not supported for target more nicely

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotcg: Use HOST_WORDS_BIGENDIAN
Richard Henderson [Mon, 31 Mar 2014 21:09:13 +0000 (14:09 -0700)]
tcg: Use HOST_WORDS_BIGENDIAN

Instead of rolling a local TCG_TARGET_WORDS_BIGENDIAN.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Fix fallback from muls2_i64 to mulu2_i64
Richard Henderson [Wed, 26 Mar 2014 18:09:44 +0000 (11:09 -0700)]
tcg: Fix fallback from muls2_i64 to mulu2_i64

Brown Bag sez, don't put the fallback code into the wrong function.
Also, check for muluh_i64 and use tcg_gen_mulu2_i64 instead of raw ops.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Use tcg_gen_mulu2_i32 in tcg_gen_muls2_i32
Richard Henderson [Wed, 26 Mar 2014 18:01:30 +0000 (11:01 -0700)]
tcg: Use tcg_gen_mulu2_i32 in tcg_gen_muls2_i32

Rather than hard-coding use of mulu2_i32, allow muluh_i32.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Relax requirement for mulu2_i32 on 32-bit hosts
Richard Henderson [Wed, 26 Mar 2014 17:59:14 +0000 (10:59 -0700)]
tcg: Relax requirement for mulu2_i32 on 32-bit hosts

Instead require either mulu2_i32 or muluh_i32.  The code in tcg-op.h
already supports looking for both.  Previous incomplete conversion?

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-s390: Remove W constraint
Richard Henderson [Mon, 31 Mar 2014 06:25:26 +0000 (02:25 -0400)]
tcg-s390: Remove W constraint

Now redundant with the type parameter to tcg_target_const_match.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-sparc: Use the type parameter to tcg_target_const_match
Richard Henderson [Mon, 31 Mar 2014 05:27:35 +0000 (22:27 -0700)]
tcg-sparc: Use the type parameter to tcg_target_const_match

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc64: Use the type parameter to tcg_target_const_match
Richard Henderson [Mon, 31 Mar 2014 05:07:27 +0000 (22:07 -0700)]
tcg-ppc64: Use the type parameter to tcg_target_const_match

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Remove w constraint
Richard Henderson [Mon, 31 Mar 2014 04:26:34 +0000 (21:26 -0700)]
tcg-aarch64: Remove w constraint

Now redundant with the type parameter to tcg_target_const_match.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Add TCGType parameter to tcg_target_const_match
Richard Henderson [Mon, 31 Mar 2014 04:22:11 +0000 (21:22 -0700)]
tcg: Add TCGType parameter to tcg_target_const_match

Most 64-bit targets need to be able to ignore the high bits
of a TCG_TYPE_I32 value.

Suggested-by: Stuart Brady <sdb@zubnet.me.uk>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Fix out of range shift in deposit optimizations
Richard Henderson [Tue, 18 Mar 2014 21:23:52 +0000 (14:23 -0700)]
tcg: Fix out of range shift in deposit optimizations

By inspection, for a deposit(x, y, 0, 64), we'd have a shift of (1<<64)
and everything else falls apart.  But we can reuse the existing deposit
logic to get this right.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotci: Mask shift counts to avoid undefined behavior
Richard Henderson [Tue, 18 Mar 2014 15:44:05 +0000 (08:44 -0700)]
tci: Mask shift counts to avoid undefined behavior

TCG now requires unspecified behavior rather than a potential crash,
bring the C shift within the letter of the law.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Mask shift quantities while folding
Richard Henderson [Tue, 18 Mar 2014 14:45:39 +0000 (07:45 -0700)]
tcg: Mask shift quantities while folding

The TCG result would be undefined, but we can at least produce one
plausible result and avoid triggering the wrath of analysis tools.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Use "unspecified behavior" for shifts
Richard Henderson [Tue, 18 Mar 2014 15:21:44 +0000 (08:21 -0700)]
tcg: Use "unspecified behavior" for shifts

Change the definition such that shifts are not allowed to crash
for any input.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Fix warning (1 bit signed bitfield entry) and replace int by bool
Stefan Weil [Fri, 21 Feb 2014 17:18:34 +0000 (18:18 +0100)]
tcg: Fix warning (1 bit signed bitfield entry) and replace int by bool

Static code analyzers complain about signed bitfields with only a single
bit. is_ld is used as a boolean value, so make it bool.

ppc64 already used bool for the 2nd argument is_ld of the local function
add_qemu_ldst_label. Modify all other TCG targets to do follow this
example.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agoFix grammar in comment
Stefan Weil [Mon, 7 Apr 2014 17:42:59 +0000 (19:42 +0200)]
Fix grammar in comment

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agodoc: grammify "allows to"
Michael Tokarev [Mon, 7 Apr 2014 09:34:58 +0000 (13:34 +0400)]
doc: grammify "allows to"

English language grammar does not allow usage
of the word "allows" directly followed by an
infinitive, declaring constructs like "something
allows to do somestuff" un-grammatical.  Often
it is possible to just insert "one" between "allows"
and "to" to make the construct grammatical, but
usually it is better to re-phrase the statement.

This patch tries to fix 4 examples of "allows to"
usage in qemu doc, but does not address comments
in the code with similar constructs.  It also adds
missing "the" in the same line.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoconfigure: Remove redundant message for -Werror
Stefan Weil [Fri, 14 Mar 2014 20:11:13 +0000 (21:11 +0100)]
configure: Remove redundant message for -Werror

The compiler flag -Werror is printed (or not printed) as any other
compiler flag which is part of QEMU_CFLAGS.

Therefore an extra output line for -Werror is redundant and can be removed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoscripts: add sample model file for Coverity Scan
Paolo Bonzini [Wed, 26 Mar 2014 11:45:49 +0000 (12:45 +0100)]
scripts: add sample model file for Coverity Scan

This is the model file that is being used for the QEMU project's scans
on scan.coverity.com.  It fixed about 30 false positives (10% of the
total) and exposed about 60 new memory leaks.

The file is not automatically used; changes to it must be propagated
to the website manually by an admin (right now Markus, Peter and me
are admins).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoxbzrle.c: Avoid undefined behaviour with signed arithmetic
Peter Maydell [Fri, 28 Mar 2014 15:12:57 +0000 (15:12 +0000)]
xbzrle.c: Avoid undefined behaviour with signed arithmetic

Use unsigned types for doing bitwise arithmetic in the xzbrle
calculations, to avoid undefined behaviour:

 xbzrle.c:99:49: runtime error: left shift of 72340172838076673
 by 7 places cannot be represented in type 'long'

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoint128.h: Avoid undefined behaviours involving signed arithmetic
Peter Maydell [Fri, 28 Mar 2014 15:12:56 +0000 (15:12 +0000)]
int128.h: Avoid undefined behaviours involving signed arithmetic

Add casts when we're performing arithmetic on the .hi parts of an
Int128, to avoid undefined behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agohw/ide/ahci.c: Avoid shift left into sign bit
Peter Maydell [Fri, 28 Mar 2014 15:12:55 +0000 (15:12 +0000)]
hw/ide/ahci.c: Avoid shift left into sign bit

Add U suffix to avoid shifting left into the sign bit, which
is undefined behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agonet: Report error when device / hub combo is not found.
Hani Benhabiles [Mon, 31 Mar 2014 23:05:14 +0000 (00:05 +0100)]
net: Report error when device / hub combo is not found.

Also convert nearby monitor_printf() call to error_report().

Signed-off-by: Hani Benhabiles <hani@linux.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoconfigure: Fix indentation of help for --enable/disable-debug-info
Peter Maydell [Mon, 31 Mar 2014 18:51:55 +0000 (19:51 +0100)]
configure: Fix indentation of help for --enable/disable-debug-info

The help text for the --enable-debug-info and --disable-debug-info
command line options was misindented: delete the stray extra space
and bring it in to line with everything else.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoqga: trivial fix for unclear documentation of guest-set-time
Amos Kong [Fri, 4 Apr 2014 15:25:02 +0000 (23:25 +0800)]
qga: trivial fix for unclear documentation of guest-set-time

We mixed the use of "guest time", "system time", "hardware time",
"RTC" in documentation, it's unclear.

This patch just added two remarks of RTC and replace two "guest time"
by "guest's system time".

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agovl: Report accelerator not supported for target more nicely
Chen Gang [Fri, 4 Apr 2014 09:39:33 +0000 (17:39 +0800)]
vl: Report accelerator not supported for target more nicely

When you ask for an accelerator not supported for your target, you get
a bogus "accelerator does not exist" message:

  $ qemu-system-arm -machine none,accel=kvm
  KVM not supported for this target
  "kvm" accelerator does not exist.
  No accelerator found!

Suppress it.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agotcg-ia64: Convert to new ldst opcodes
Richard Henderson [Tue, 4 Mar 2014 17:35:30 +0000 (09:35 -0800)]
tcg-ia64: Convert to new ldst opcodes

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Move part of softmmu slow path out of line
Richard Henderson [Fri, 6 Sep 2013 06:06:59 +0000 (02:06 -0400)]
tcg-ia64: Move part of softmmu slow path out of line

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Convert to new ldst helpers
Richard Henderson [Fri, 6 Sep 2013 04:38:52 +0000 (00:38 -0400)]
tcg-ia64: Convert to new ldst helpers

Still inline, but updated to the new routines.  Always use the LE
helpers, reusing the bswap between the fast and slot paths.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Reduce code duplication in tcg_out_qemu_ld
Richard Henderson [Fri, 6 Sep 2013 00:50:54 +0000 (20:50 -0400)]
tcg-ia64: Reduce code duplication in tcg_out_qemu_ld

The only differences were in the bswap insns emitted.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Move tlb addend load into tlb read
Richard Henderson [Fri, 6 Sep 2013 00:32:49 +0000 (20:32 -0400)]
tcg-ia64: Move tlb addend load into tlb read

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Move bswap for store into tlb load
Richard Henderson [Fri, 6 Sep 2013 00:02:51 +0000 (20:02 -0400)]
tcg-ia64: Move bswap for store into tlb load

Saving at least two cycles per store, and cleaning up the code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Re-bundle the tlb load
Richard Henderson [Thu, 5 Sep 2013 23:46:56 +0000 (19:46 -0400)]
tcg-ia64: Re-bundle the tlb load

This sequencing requires 5 stop bits instead of 6, and has room left
over to pre-load the tlb addend, and bswap data prior to being stored.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Optimize small arguments to exit_tb
Richard Henderson [Thu, 31 Oct 2013 19:19:23 +0000 (15:19 -0400)]
tcg-ia64: Optimize small arguments to exit_tb

Saves one bundle for the common case of exit_tb 0.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140417-1' into...
Peter Maydell [Thu, 17 Apr 2014 20:37:26 +0000 (21:37 +0100)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20140417-1' into staging

target-arm queue:
 * AArch64 system mode support; this is all the CPU emulation code
   but not the virt board support
 * cadence_ttc match register bugfix
 * Allwinner A10 PIC, PIT and ethernet fixes
   [with update to avoid duplicate typedef]
 * zynq-slcr rewrite
 * cadence_gem bugfix
 * fix for SMLALD/SMLSLD insn in A32
 * fix for SQXTUN in A64

# gpg: Signature made Thu 17 Apr 2014 21:35:57 BST using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"

* remotes/pmaydell/tags/pull-target-arm-20140417-1: (51 commits)
  target-arm: A64: fix unallocated test of scalar SQXTUN
  arm: translate.c: Fix smlald Instruction
  net: cadence_gem: Make phy respond to broadcast
  misc: zynq_slcr: Make DB_PRINTs always compile
  misc: zynq_slcr: Convert SBD::init to object init
  misc: zynq-slcr: Rewrite
  allwinner-emac: update irq status after writes to interrupt registers
  allwinner-emac: set autonegotiation complete bit on link up
  allwinner-a10-pit: implement prescaler and source selection
  allwinner-a10-pit: use level triggered interrupts
  allwinner-a10-pit: avoid generation of spurious interrupts
  allwinner-a10-pic: fix behaviour of pending register
  allwinner-a10-pic: set vector address when an interrupt is pending
  timer: cadence_ttc: Fix match register write logic
  target-arm/gdbstub64.c: remove useless 'break' statement.
  target-arm: Dump 32-bit CPU state if 64 bit CPU is in AArch32
  target-arm: Handle the CPU being in AArch32 mode in the AArch64 set_pc
  target-arm: Make Cortex-A15 CBAR read-only
  target-arm: Implement CBAR for Cortex-A57
  target-arm: Implement Cortex-A57 implementation-defined system registers
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: A64: fix unallocated test of scalar SQXTUN
Alex Bennée [Wed, 16 Apr 2014 11:29:39 +0000 (12:29 +0100)]
target-arm: A64: fix unallocated test of scalar SQXTUN

The test for the U bit was incorrectly inverted in the scalar case of SQXTUN.
This doesn't affect the vector case as the U bit is used to select XTN(2).

Reported-by: Hao Liu <hao.liu@arm.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoarm: translate.c: Fix smlald Instruction
Peter Crosthwaite [Thu, 17 Apr 2014 03:20:52 +0000 (20:20 -0700)]
arm: translate.c: Fix smlald Instruction

The smlald (and probably smlsld) instruction was doing incorrect sign
extensions of the operands amongst 64bit result calculation. The
instruction psuedo-code is:

 operand2 = if m_swap then ROR(R[m],16) else R[m];
 product1 = SInt(R[n]<15:0>) * SInt(operand2<15:0>);
 product2 = SInt(R[n]<31:16>) * SInt(operand2<31:16>);
 result = product1 + product2 + SInt(R[dHi]:R[dLo]);
 R[dHi] = result<63:32>;
 R[dLo] = result<31:0>;

The result calculation should be done in 64 bit arithmetic, and hence
product1 and product2 should be sign extended to 64b before calculation.

The current implementation was adding product1 and product2 together
then sign-extending the intermediate result leading to false negatives.

E.G. if product1 = product2 = 0x4000000, their sum = 0x80000000, which
will be incorrectly interpreted as -ve on sign extension.

We fix by doing the 64b extensions on both product1 and product2 before
any addition/subtraction happens.

We also fix where we were possibly incorrectly setting the Q saturation
flag for SMLSLD, which the ARM ARM specifically says is not set.

Reported-by: Christina Smith <christina.smith@xilinx.com>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 2cddb6f5a15be4ab8d2160f3499d128ae93d304d.1397704570.git.peter.crosthwaite@xilinx.com
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agonet: cadence_gem: Make phy respond to broadcast
Peter Crosthwaite [Fri, 4 Apr 2014 06:55:19 +0000 (23:55 -0700)]
net: cadence_gem: Make phy respond to broadcast

Phys must respond to address 0 by specification. Implement.

Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 6f4d53b04ddbfb19895bfb61a595e69f1c08859a.1396594056.git.peter.crosthwaite@xilinx.com
Reviewed-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agomisc: zynq_slcr: Make DB_PRINTs always compile
Peter Crosthwaite [Tue, 15 Apr 2014 18:49:11 +0000 (19:49 +0100)]
misc: zynq_slcr: Make DB_PRINTs always compile

Change the DB_PRINT macro over to a regular if() rather than
conditional compilation to give constant compile testing of formats.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 942477847353c5cff5f45a228cc88c633dc012f3.1396503037.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agomisc: zynq_slcr: Convert SBD::init to object init
Peter Crosthwaite [Tue, 15 Apr 2014 18:49:11 +0000 (19:49 +0100)]
misc: zynq_slcr: Convert SBD::init to object init

To bring it up to date with styling guidelines.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 2e837af80a18216c21e73241032e048f39d78b99.1396503037.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agomisc: zynq-slcr: Rewrite
Peter Crosthwaite [Tue, 15 Apr 2014 18:49:11 +0000 (19:49 +0100)]
misc: zynq-slcr: Rewrite

Near total rewrite of this device model. It is stylistically
obsolete, has numerous coverity fails and is not up to date with latest
Xilinx documentation. Fix.

The registers are flattened into a single array. This greatly simplifies
the MMIO accessor functions.

We take the oppurtunity to update the register Macro definitions to
match the latest TRM. Xilinx has de-documented some regs hence there are
some straight deletions. We only do this however in the case or a stock
read-as-written reset-zero register. Non-zero resets are always
preserved. New register definitions are added as needed.

This all comes with a VMSD version break as the union layout from before
was a bit strange and we are better off without it.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 3aa016167b352ed224666909217137285fd3351d.1396503037.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-emac: update irq status after writes to interrupt registers
Beniamino Galvani [Tue, 25 Mar 2014 18:22:10 +0000 (19:22 +0100)]
allwinner-emac: update irq status after writes to interrupt registers

The irq line status must be updated after writes to the INT_CTL and
INT_STA registers.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-8-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-emac: set autonegotiation complete bit on link up
Beniamino Galvani [Tue, 25 Mar 2014 18:22:09 +0000 (19:22 +0100)]
allwinner-emac: set autonegotiation complete bit on link up

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-7-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-a10-pit: implement prescaler and source selection
Beniamino Galvani [Tue, 25 Mar 2014 18:22:08 +0000 (19:22 +0100)]
allwinner-a10-pit: implement prescaler and source selection

This implements the prescaler and source fields of the timer control
register. The source for each timer can be selected among 4 clock
inputs whose frequencies are set through model properties.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-6-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-a10-pit: use level triggered interrupts
Beniamino Galvani [Tue, 25 Mar 2014 18:22:07 +0000 (19:22 +0100)]
allwinner-a10-pit: use level triggered interrupts

Convert the interrupt generation logic to the use of level triggered
interrupts.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-5-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-a10-pit: avoid generation of spurious interrupts
Beniamino Galvani [Tue, 25 Mar 2014 18:22:06 +0000 (19:22 +0100)]
allwinner-a10-pit: avoid generation of spurious interrupts

The model was generating interrupts for all enabled timers after the
expiration of one of them. Avoid this by passing explicitly the timer
index to the callback function.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Li Guang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-4-git-send-email-b.galvani@gmail.com
[PMM: avoid duplicate typedef of AwA10PITState]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-a10-pic: fix behaviour of pending register
Beniamino Galvani [Tue, 25 Mar 2014 18:22:05 +0000 (19:22 +0100)]
allwinner-a10-pic: fix behaviour of pending register

The pending register is read-only and the value returned upon a read
reflects the state of irq input pins (interrupts are level triggered).
This patch implements such behaviour.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Li Guang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1395771730-16882-3-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoallwinner-a10-pic: set vector address when an interrupt is pending
Beniamino Galvani [Tue, 25 Mar 2014 18:22:04 +0000 (19:22 +0100)]
allwinner-a10-pic: set vector address when an interrupt is pending

This patch implements proper updating of the vector register which
should hold, according to the A10 user manual, the vector address for
the interrupt currently active on the CPU IRQ input.

Interrupt priority is not implemented at the moment and thus the first
pending interrupt is returned.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Li Guang <lig.fnst@cn.fujitsu.com>
Message-id: 1395771730-16882-2-git-send-email-b.galvani@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotimer: cadence_ttc: Fix match register write logic
Peter Crosthwaite [Tue, 1 Apr 2014 04:31:09 +0000 (21:31 -0700)]
timer: cadence_ttc: Fix match register write logic

This switch logic should not fall through. Fix.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 74147b4c017c904364955cc73107f90e6ac8ba74.1396326389.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm/gdbstub64.c: remove useless 'break' statement.
Chen Gang [Tue, 18 Mar 2014 00:31:16 +0000 (08:31 +0800)]
target-arm/gdbstub64.c: remove useless 'break' statement.

Clean up useless 'break' statement after 'return' statement.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Dump 32-bit CPU state if 64 bit CPU is in AArch32
Peter Maydell [Tue, 15 Apr 2014 18:19:15 +0000 (19:19 +0100)]
target-arm: Dump 32-bit CPU state if 64 bit CPU is in AArch32

For system mode, we may have a 64 bit CPU which is currently executing
in AArch32 state; if we're dumping CPU state to the logs we should
therefore show the correct state for the current execution state,
rather than hardwiring it based on the type of the CPU. For consistency
with how we handle translation, we leave the 32 bit dump function
as the default, and have it hand off control to the 64 bit dump code
if we're in AArch64 mode.

Reported-by: Rob Herring <rob.herring@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Handle the CPU being in AArch32 mode in the AArch64 set_pc
Peter Maydell [Tue, 15 Apr 2014 18:18:49 +0000 (19:18 +0100)]
target-arm: Handle the CPU being in AArch32 mode in the AArch64 set_pc

The AArch64 implementation of the set_pc method needs to be updated to
handle the possibility that the CPU is in AArch32 mode; otherwise there
are weird crashes when doing interprocessing in system emulation mode
when an interrupt occurs and we fail to resynchronize the 32-bit PC
with the TB we need to execute next.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Make Cortex-A15 CBAR read-only
Peter Maydell [Tue, 15 Apr 2014 18:18:49 +0000 (19:18 +0100)]
target-arm: Make Cortex-A15 CBAR read-only

The Cortex-A15's CBAR register is actually read-only (unlike that
of the Cortex-A9). Correct our model to match the hardware.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement CBAR for Cortex-A57
Peter Maydell [Tue, 15 Apr 2014 18:18:49 +0000 (19:18 +0100)]
target-arm: Implement CBAR for Cortex-A57

The Cortex-A57, like most of the other ARM cores, has a CBAR
register which defines the base address of the per-CPU
peripherals. However it has a 64-bit view as well as a
32-bit view; expand the QOM reset-cbar property from UINT32
to UINT64 so this can be specified, and implement the
32-bit and 64-bit views of a 64-bit CBAR.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement Cortex-A57 implementation-defined system registers
Peter Maydell [Tue, 15 Apr 2014 18:18:48 +0000 (19:18 +0100)]
target-arm: Implement Cortex-A57 implementation-defined system registers

Implement a subset of the Cortex-A57's implementation defined system
registers. We provide RAZ/WI or reads-as-constant/writes-ignored
implementations of the various control and syndrome reigsters.
We do not implement registers which provide direct access to and
manipulation of the L1 cache, since QEMU doesn't implement caches.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement RVBAR register
Peter Maydell [Tue, 15 Apr 2014 18:18:48 +0000 (19:18 +0100)]
target-arm: Implement RVBAR register

Implement the AArch64 RVBAR register, which indicates the reset
address. Since the reset address is implementation defined and
usually configurable by setting config signals in hardware, we
also provide a QOM property so it can be set at board level if
necessary.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 address translation operations
Peter Maydell [Tue, 15 Apr 2014 18:18:48 +0000 (19:18 +0100)]
target-arm: Implement AArch64 address translation operations

Implement the AArch64 address translation operations.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement auxiliary fault status registers
Peter Maydell [Tue, 15 Apr 2014 18:18:47 +0000 (19:18 +0100)]
target-arm: Implement auxiliary fault status registers

Implement the auxiliary fault status registers AFSR0_EL1 and
AFSR1_EL1. These are present on v7 and later, and have IMPDEF
behaviour; we choose to RAZ/WI for all cores.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Replace wildcarded cpreg definitions with precise ones for ARMv8
Peter Maydell [Tue, 15 Apr 2014 18:18:47 +0000 (19:18 +0100)]
target-arm: Replace wildcarded cpreg definitions with precise ones for ARMv8

Many of the reginfo definitions in cp_reginfo[] use CP_ANY wildcards.
This is for a combination of reasons:
 * early ARM implementations really did underdecode
 * earlier versions of QEMU underdecoded and we can't tighten
   this up because we don't know if guests really require this or not
 * implementation convenience

For ARMv8 the architecture has tightened things up and system and
coprocessor registers are always specifically decoded. We take
advantage of this opportunity for a clean break by restricting
our CP_ANY wildcarded reginfo to pre-v8 CPUs, and providing
specifically decoded versions where necessary for v8 CPUs.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Don't expose wildcard ID register definitions for ARMv8
Peter Maydell [Tue, 15 Apr 2014 18:18:47 +0000 (19:18 +0100)]
target-arm: Don't expose wildcard ID register definitions for ARMv8

In ARMv8 the 32 bit coprocessor ID register space is tidied up to
remove the wildcarded aliases of the MIDR and the RAZ behaviour
for the unassigned space where crm = 3..7. Make sure we don't
expose thes wildcards for v8 cores. This means we need to have
a specific implementation for REVIDR, an IMPDEF register which
may be the same as the MIDR (and which we always implement as such).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Remove THUMB2EE feature from AArch64 'any' CPU
Peter Maydell [Tue, 15 Apr 2014 18:18:46 +0000 (19:18 +0100)]
target-arm: Remove THUMB2EE feature from AArch64 'any' CPU

The AArch64 usermode 'any' CPU type was accidentally specified
with the ARM_FEATURE_THUMB2EE bit set. This is incorrect since
ARMv8 removes Thumb2EE completely. Since we never implemented
Thumb2EE anyway having the feature bit set was fairly harmless
for user-mode, but the correct thing is to not set it at all.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement ISR_EL1 register
Peter Maydell [Tue, 15 Apr 2014 18:18:46 +0000 (19:18 +0100)]
target-arm: Implement ISR_EL1 register

Implement the ISR_EL1 register. This is actually present in
ARMv7 as well but was previously unimplemented. It is a
read-only register that indicates whether interrupts are
currently pending.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 view of ACTLR
Peter Maydell [Tue, 15 Apr 2014 18:18:45 +0000 (19:18 +0100)]
target-arm: Implement AArch64 view of ACTLR

Implement the AArch64 view of the ACTLR (auxiliary control
register). Note that QEMU internally tends to call this
AUXCR for historical reasons.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 view of CONTEXTIDR
Peter Maydell [Tue, 15 Apr 2014 18:18:45 +0000 (19:18 +0100)]
target-arm: Implement AArch64 view of CONTEXTIDR

Implement AArch64 view of the CONTEXTIDR register.
We tighten up the condition when we flush the TLB on a CONTEXTIDR
write to avoid needlessly flushing the TLB every time on a 64
bit system (and also on a 32 bit system using LPAE, as a bonus).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 views of AArch32 ID registers
Peter Maydell [Tue, 15 Apr 2014 18:18:45 +0000 (19:18 +0100)]
target-arm: Implement AArch64 views of AArch32 ID registers

All the AArch32 ID registers are visible from AArch64
(in addition to the AArch64-specific ID_AA64* registers).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Add Cortex-A57 processor
Peter Maydell [Tue, 15 Apr 2014 18:18:44 +0000 (19:18 +0100)]
target-arm: Add Cortex-A57 processor

Add Cortex-A57 processor.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement ARMv8 MVFR registers
Peter Maydell [Tue, 15 Apr 2014 18:18:44 +0000 (19:18 +0100)]
target-arm: Implement ARMv8 MVFR registers

For ARMv8 there are two changes to the MVFR media feature registers:
 * there is a new MVFR2 which is accessible from 32 bit code
 * 64 bit code accesses these via the usual sysreg instructions
   rather than with a floating-point specific instruction

Implement this.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 EL1 exception handling
Rob Herring [Tue, 15 Apr 2014 18:18:44 +0000 (19:18 +0100)]
target-arm: Implement AArch64 EL1 exception handling

Implement exception handling for AArch64 EL1. Exceptions from AArch64 or
AArch32 EL0 are supported.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: fixed minor style nits; updated to match changes in
 previous patches; added some of the simpler cases of
 illegal-exception-return support]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Move arm_log_exception() into internals.h
Peter Maydell [Tue, 15 Apr 2014 18:18:43 +0000 (19:18 +0100)]
target-arm: Move arm_log_exception() into internals.h

Move arm_log_exception() into internals.h so we can use it from
helper-a64.c for the AArch64 exception entry code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 SPSR_EL1
Peter Maydell [Tue, 15 Apr 2014 18:18:43 +0000 (19:18 +0100)]
target-arm: Implement AArch64 SPSR_EL1

Implement the AArch64 SPSR_EL1. For compatibility with how KVM
handles SPSRs and with the architectural mapping between AArch32
and AArch64, we put this in the banked_spsr[] array in the slot
that is used for SVC in AArch32. This means we need to extend the
array from uint32_t to uint64_t, which requires some reworking
of the 32 bit KVM save/restore code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement SP_EL0, SP_EL1
Peter Maydell [Tue, 15 Apr 2014 18:18:43 +0000 (19:18 +0100)]
target-arm: Implement SP_EL0, SP_EL1

Implement handling for the AArch64 SP_EL0 system register.
This holds the EL0 stack pointer, and is only accessible when
it's not being used as the stack pointer, ie when we're in EL1
and EL1 is using its own stack pointer. We also provide a
definition of the SP_EL1 register; this isn't guest visible
as a system register for an implementation like QEMU which
doesn't provide EL2 or EL3; however it is useful for ensuring
the underlying state is migrated.

We need to update the state fields in the CPU state whenever
we switch stack pointers; this happens when we take an exception
and also when SPSEL is used to change the bit in PSTATE which
indicates which stack pointer EL1 should use.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Add AArch64 ELR_EL1 register.
Peter Maydell [Tue, 15 Apr 2014 18:18:42 +0000 (19:18 +0100)]
target-arm: Add AArch64 ELR_EL1 register.

Add the AArch64 ELR_EL1 register.

Note that this does not live in env->cp15: for KVM migration
compatibility we need to migrate it separately rather than
as part of the system registers, because the KVM-to-userspace
interface puts it in the struct kvm_regs rather than making
them visible via the ONE_REG ioctls.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 views of fault status and data registers
Rob Herring [Tue, 15 Apr 2014 18:18:42 +0000 (19:18 +0100)]
target-arm: Implement AArch64 views of fault status and data registers

Implement AArch64 views of ESR_EL1 and FAR_EL1, and make the 32 bit
DFSR, DFAR, IFAR share state with them as architecturally specified.
The IFSR doesn't share state with any AArch64 register visible at EL1,
so just rename the state field without widening it to 64 bits.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: Minor tweaks; fix some bugs involving inconsistencies between
 use of offsetof() or offsetoflow32() and struct field width]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Use dedicated CPU state fields for ARM946 access bit registers
Peter Maydell [Tue, 15 Apr 2014 18:18:41 +0000 (19:18 +0100)]
target-arm: Use dedicated CPU state fields for ARM946 access bit registers

The ARM946 model currently uses the c5_data and c5_insn fields in the CPU
state struct to store the contents of its access permission registers.
This is confusing and a good source of bugs because for all the MMU-based
CPUs those fields are fault status and fault address registers, which
behave completely differently; they just happen to use the same cpreg
encoding. Split them out to use their own fields instead.

These registers are only present in PMSAv5 MPU systems (of which the
ARM946 is our only current example); PMSAv6 and PMSAv7 (which we have
no implementations of) handle access permissions differently. We name
the new state fields accordingly.

Note that this change fixes a bug where a data abort or prefetch abort
on the ARM946 would accidentally corrupt the access permission registers
because the interrupt handling code assumed the c5_data and c5_insn
fields were always fault status registers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: A64: Implement DC ZVA
Peter Maydell [Tue, 15 Apr 2014 18:18:41 +0000 (19:18 +0100)]
target-arm: A64: Implement DC ZVA

Implement the DC ZVA instruction, which clears a block of memory.
The fast path obtains a pointer to the underlying RAM via the TCG TLB
data structure so we can do a direct memset(), with fallback to a
simple byte-store loop in the slow path.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Don't mention PMU in debug feature register
Peter Maydell [Tue, 15 Apr 2014 18:18:41 +0000 (19:18 +0100)]
target-arm: Don't mention PMU in debug feature register

Suppress the ID_AA64DFR0_EL1 PMUVer field, even if the CPU specific
value claims that it exists. QEMU doesn't currently implement it,
and not advertising it prevents the guest from trying to use it
and getting UNDEFs on unimplemented registers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
This is arguably a hack, but otherwise Linux tries to prod
half a dozen PMU sysregs.

10 years agotarget-arm: Add v8 mmu translation support
Rob Herring [Tue, 15 Apr 2014 18:18:40 +0000 (19:18 +0100)]
target-arm: Add v8 mmu translation support

Add support for v8 page table walks. This supports stage 1 translations
for 4KB, 16KB and 64KB page sizes starting with 0 or 1 level.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: fix style nits, fold in 16/64K page support patch, use
 arm_el_is_aa64() to decide whether to do 64 bit page table walk]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Fix VFP enables for AArch32 EL0 under AArch64 EL1
Peter Maydell [Tue, 15 Apr 2014 18:18:40 +0000 (19:18 +0100)]
target-arm: Fix VFP enables for AArch32 EL0 under AArch64 EL1

The current A32/T32 decoder bases its "is VFP/Neon enabled?" check
on the FPSCR.EN bit. This is correct if EL1 is AArch32, but for
an AArch64 EL1 the logic is different: it must act as if FPSCR.EN
is always set. Instead, trapping must happen according to CPACR
bits for cp10/cp11; these cover all of FP/Neon, including the
FPSCR/FPSID/MVFR register accesses which FPSCR.EN does not affect.
Add support for CPACR checks (which are also required for ARMv7,
but were unimplemented because Linux happens not to use them)
and make sure they generate exceptions with the correct syndrome.

We actually return incorrect syndrome information for cases
where FP is disabled but the specific instruction bit pattern
is unallocated: strictly these should be the Uncategorized
exception, not a "SIMD disabled" exception. This should be
mostly harmless, and the structure of the A32/T32 VFP/Neon
decoder makes it painful to put the 'FP disabled?' checks in
the right places.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: A64: Add assertion that FP access was checked
Peter Maydell [Tue, 15 Apr 2014 18:18:40 +0000 (19:18 +0100)]
target-arm: A64: Add assertion that FP access was checked

Because unallocated encodings generate different exception syndrome
information from traps due to FP being disabled, we can't do a single
"is fp access disabled" check at a high level in the decode tree.
To help in catching bugs where the access check was forgotten in some
code path, we set this flag when the access check is done, and assert
that it is set at the point where we actually touch the FP regs.

This requires us to pass the DisasContext to the vec_reg_offset
and fp_reg_offset functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: A64: Correctly fault FP/Neon if CPACR.FPEN set
Peter Maydell [Tue, 15 Apr 2014 18:18:39 +0000 (19:18 +0100)]
target-arm: A64: Correctly fault FP/Neon if CPACR.FPEN set

For the A64 instruction set, the only FP/Neon disable trap
is the CPACR FPEN bits, which may indicate "enabled", "disabled"
or "disabled for EL0". Add a bit to the AArch64 tb flags indicating
whether FP/Neon access is currently enabled and make the decoder
emit code to raise exceptions on use of FP/Neon insns if it is not.

We use a new flag in DisasContext rather than borrowing the
existing vfp_enabled flag because the A32/T32 decoder is going
to need both.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
I'm aware this is a rather hard to review patch; sorry.
I have done an exhaustive check that we have fp access checks
in all code paths with the aid of the assertions added in the
next patch plus the code-coverage hack patch I posted to the
list earlier.

This patch is correct as of
09e037354 target-arm: A64: Add saturating accumulate ops (USQADD/SUQADD)
which was the last of the Neon insns to be added, so assuming
no refactoring of the code it should be fine.

10 years agotarget-arm: Provide syndrome information for MMU faults
Rob Herring [Tue, 15 Apr 2014 18:18:39 +0000 (19:18 +0100)]
target-arm: Provide syndrome information for MMU faults

Set up the required syndrome information when we detect an MMU fault.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
[PMM: split out from exception handling patch, tweaked to bring
 in line with how we create other kinds of syndrome information]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Add support for generating exceptions with syndrome information
Peter Maydell [Tue, 15 Apr 2014 18:18:38 +0000 (19:18 +0100)]
target-arm: Add support for generating exceptions with syndrome information

Add new helpers exception_with_syndrome (for generating an exception
with syndrome information) and exception_uncategorized (for generating
an exception with "Unknown or Uncategorized Reason", which have a syndrome
register value of zero), and use them to generate the correct syndrome
information for exceptions which are raised directly from generated code.

This patch includes moving the A32/T32 gen_exception_insn functions
further up in the source file; they will be needed for "VFP/Neon disabled"
exception generation later.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Provide correct syndrome information for cpreg access traps
Peter Maydell [Tue, 15 Apr 2014 18:18:38 +0000 (19:18 +0100)]
target-arm: Provide correct syndrome information for cpreg access traps

For exceptions taken to AArch64, if a coprocessor/system register
access fails due to a trap or enable bit then the syndrome information
must include details of the failing instruction (crn/crm/opc1/opc2
fields, etc). Make the decoder construct the syndrome information
at translate time so it can be passed at runtime to the access-check
helper function and used as required.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Define exception record for AArch64 exceptions
Peter Maydell [Tue, 15 Apr 2014 18:18:38 +0000 (19:18 +0100)]
target-arm: Define exception record for AArch64 exceptions

For AArch32 exceptions, the only information provided about
the cause of an exception is the individual exception type (data
abort, undef, etc), which we store in cs->exception_index. For
AArch64, the CPU provides much more detail about the cause of
the exception, which can be found in the syndrome register.
Create a set of fields in CPUARMState which must be filled in
whenever an exception is raised, so that exception entry can
correctly fill in the syndrome register for the guest.
This includes the information which in AArch32 appears in
the DFAR and IFAR (fault address registers) and the DFSR
and IFSR (fault status registers) for data aborts and
prefetch aborts, since if we end up taking the MMU fault
to AArch64 rather than AArch32 this will need to end up
in different system registers.

This patch does a refactoring which moves the setting of the
AArch32 DFAR/DFSR/IFAR/IFSR from the point where the exception
is raised to the point where it is taken. (This is no change
for cores with an MMU, retains the existing clearly incorrect
behaviour for ARM946 of trashing the MP access permissions
registers which share the c5_data and c5_insn state fields,
and has no effect for v7M because we don't implement its
MPU fault status or address registers.)

As a side effect of the cleanup we fix a bug in the AArch64
linux-user mode code where we were passing a 64 bit fault
address through the 32 bit c6_data/c6_insn fields: it now
goes via the always-64-bit exception.vaddress.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Implement AArch64 DAIF system register
Peter Maydell [Tue, 15 Apr 2014 18:18:37 +0000 (19:18 +0100)]
target-arm: Implement AArch64 DAIF system register

Implement the DAIF system register which is a view of the
DAIF bits in PSTATE. To avoid needing a readfn, we widen
the daif field in CPUARMState to uint64_t.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agotarget-arm: Split out private-to-target functions into internals.h
Peter Maydell [Tue, 15 Apr 2014 18:18:37 +0000 (19:18 +0100)]
target-arm: Split out private-to-target functions into internals.h

Currently cpu.h defines a mixture of functions and types needed by
the rest of QEMU and those needed only by files within target-arm/.
Split the latter out into a new header so they aren't needlessly
exposed further than required.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10 years agoMerge remote-tracking branch 'remotes/rth/tcg-aarch-6-5' into staging
Peter Maydell [Thu, 17 Apr 2014 19:54:38 +0000 (20:54 +0100)]
Merge remote-tracking branch 'remotes/rth/tcg-aarch-6-5' into staging

* remotes/rth/tcg-aarch-6-5: (25 commits)
  tcg-aarch64: Use tcg_out_mov in preference to tcg_out_movr
  tcg-aarch64: Prefer unsigned offsets before signed offsets for ldst
  tcg-aarch64: Introduce tcg_out_insn_3312, _3310, _3313
  tcg-aarch64: Merge aarch64_ldst_get_data/type into tcg_out_op
  tcg-aarch64: Introduce tcg_out_insn_3507
  tcg-aarch64: Support stores of zero
  tcg-aarch64: Implement TCG_TARGET_HAS_new_ldst
  tcg-aarch64: Pass qemu_ld/st arguments directly
  tcg-aarch64: Use TCGMemOp in qemu_ld/st
  tcg-aarch64: Use ADR to pass the return address to the ld/st helpers
  tcg-aarch64: Use tcg_out_call for qemu_ld/st
  tcg-aarch64: Avoid add with zero in tlb load
  tcg-aarch64: Implement tcg_register_jit
  tcg-aarch64: Introduce tcg_out_insn_3314
  tcg-aarch64: Reuse LR in translated code
  tcg-aarch64: Use CBZ and CBNZ
  tcg-aarch64: Create tcg_out_brcond
  tcg-aarch64: Use symbolic names for branches
  tcg-aarch64: Use adrp in tcg_out_movi
  tcg-aarch64: Special case small constants in tcg_out_movi
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoOpen 2.1 development tree
Peter Maydell [Thu, 17 Apr 2014 19:39:32 +0000 (20:39 +0100)]
Open 2.1 development tree

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoUpdate version for v2.0.0 release
Peter Maydell [Thu, 17 Apr 2014 12:41:45 +0000 (13:41 +0100)]
Update version for v2.0.0 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotcg-aarch64: Use tcg_out_mov in preference to tcg_out_movr
Richard Henderson [Thu, 3 Apr 2014 18:41:34 +0000 (14:41 -0400)]
tcg-aarch64: Use tcg_out_mov in preference to tcg_out_movr

It's the more canonical interface.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Prefer unsigned offsets before signed offsets for ldst
Richard Henderson [Tue, 4 Mar 2014 04:03:51 +0000 (23:03 -0500)]
tcg-aarch64: Prefer unsigned offsets before signed offsets for ldst

The assembler seems to prefer them, perhaps we should too.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Introduce tcg_out_insn_3312, _3310, _3313
Richard Henderson [Tue, 4 Mar 2014 01:11:49 +0000 (17:11 -0800)]
tcg-aarch64: Introduce tcg_out_insn_3312, _3310, _3313

Replace aarch64_ldst_op_data with AArch64LdstType, as it wasn't encoded
for the proper shift for the field and was confusing.

Merge aarch64_ldst_op_data, AArch64LdstType, and a few stray opcode bits
into a single I3312_* argument, eliminating some magic numbers from the
helper functions.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Merge aarch64_ldst_get_data/type into tcg_out_op
Richard Henderson [Tue, 4 Mar 2014 00:36:01 +0000 (16:36 -0800)]
tcg-aarch64: Merge aarch64_ldst_get_data/type into tcg_out_op

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Introduce tcg_out_insn_3507
Richard Henderson [Tue, 4 Mar 2014 00:21:27 +0000 (16:21 -0800)]
tcg-aarch64: Introduce tcg_out_insn_3507

Cleaning up the implementation of REV and REV16 at the same time.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Support stores of zero
Richard Henderson [Tue, 4 Mar 2014 02:58:46 +0000 (21:58 -0500)]
tcg-aarch64: Support stores of zero

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Implement TCG_TARGET_HAS_new_ldst
Richard Henderson [Thu, 27 Feb 2014 19:42:18 +0000 (14:42 -0500)]
tcg-aarch64: Implement TCG_TARGET_HAS_new_ldst

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Pass qemu_ld/st arguments directly
Richard Henderson [Thu, 3 Apr 2014 17:54:28 +0000 (13:54 -0400)]
tcg-aarch64: Pass qemu_ld/st arguments directly

Instead of passing them the "args" array.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Use TCGMemOp in qemu_ld/st
Richard Henderson [Wed, 26 Feb 2014 23:54:38 +0000 (18:54 -0500)]
tcg-aarch64: Use TCGMemOp in qemu_ld/st

Making the bswap conditional on the memop instead of a compile-time test.

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>