~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to debian/patches/arm64/0035-target-arm-A64-add-support-for-compare-and-branch-im.patch

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-02-04 12:13:08 UTC
  • mfrom: (10.1.45 sid)
  • Revision ID: package-import@ubuntu.com-20140204121308-1xq92lrfs75agw2g
Tags: 1.7.0+dfsg-3ubuntu1~ppa1
* Merge 1.7.0+dfsg-3 from debian.  Remaining changes:
  - debian/patches/ubuntu:
    * expose-vmx_qemu64cpu.patch
    * linaro (omap3) and arm64 patches
    * ubuntu/target-ppc-add-stubs-for-kvm-breakpoints: fix FTBFS
      on ppc
    * ubuntu/CVE-2013-4377.patch: fix denial of service via virtio
  - debian/qemu-system-x86.modprobe: set kvm_intel nested=1 options
  - debian/control:
    * add arm64 to Architectures
    * add qemu-common and qemu-system-aarch64 packages
  - debian/qemu-system-common.install: add debian/tmp/usr/lib
  - debian/qemu-system-common.preinst: add kvm group
  - debian/qemu-system-common.postinst: remove acl placed by udev,
    and add udevadm trigger.
  - qemu-system-x86.links: add eepro100.rom, remove pxe-virtio,
    pxe-e1000 and pxe-rtl8139.
  - add qemu-system-x86.qemu-kvm.upstart and .default
  - qemu-user-static.postinst-in: remove arm64 binfmt
  - debian/rules:
    * allow parallel build
    * add aarch64 to system_targets and sys_systems
    * add qemu-kvm-spice links
    * install qemu-system-x86.modprobe
  - add debian/qemu-system-common.links for OVMF.fd link
* Remove kvm-img, kvm-nbd, kvm-ifup and kvm-ifdown symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From ecfe89ee74b09369f70d9e6320bd7e7fd6f7f430 Mon Sep 17 00:00:00 2001
2
 
From: Alexander Graf <agraf@suse.de>
3
 
Date: Tue, 17 Dec 2013 19:42:33 +0000
4
 
Subject: [PATCH 35/49] target-arm: A64: add support for compare and branch imm
5
 
 
6
 
This patch adds emulation for the compare and branch insns,
7
 
CBZ and CBNZ.
8
 
 
9
 
Signed-off-by: Alexander Graf <agraf@suse.de>
10
 
[claudio: adapted to new decoder,
11
 
          compare with immediate 0,
12
 
          introduce read_cpu_reg to get the 0 extension on (!sf)]
13
 
Signed-off-by: Claudio Fontana <claudio.fontana@linaro.org>
14
 
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
 
Reviewed-by: Richard Henderson <rth@twiddle.net>
16
 
---
17
 
 target-arm/translate-a64.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
18
 
 1 file changed, 44 insertions(+), 2 deletions(-)
19
 
 
20
 
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
21
 
index 1d04303..5ae3a85 100644
22
 
--- a/target-arm/translate-a64.c
23
 
+++ b/target-arm/translate-a64.c
24
 
@@ -202,6 +202,25 @@ static TCGv_i64 cpu_reg(DisasContext *s, int reg)
25
 
     }
26
 
 }
27
 
 
28
 
+/* read a cpu register in 32bit/64bit mode. Returns a TCGv_i64
29
 
+ * representing the register contents. This TCGv is an auto-freed
30
 
+ * temporary so it need not be explicitly freed, and may be modified.
31
 
+ */
32
 
+static TCGv_i64 read_cpu_reg(DisasContext *s, int reg, int sf)
33
 
+{
34
 
+    TCGv_i64 v = new_tmp_a64(s);
35
 
+    if (reg != 31) {
36
 
+        if (sf) {
37
 
+            tcg_gen_mov_i64(v, cpu_X[reg]);
38
 
+        } else {
39
 
+            tcg_gen_ext32u_i64(v, cpu_X[reg]);
40
 
+        }
41
 
+    } else {
42
 
+        tcg_gen_movi_i64(v, 0);
43
 
+    }
44
 
+    return v;
45
 
+}
46
 
+
47
 
 /*
48
 
  * the instruction disassembly implemented here matches
49
 
  * the instruction encoding classifications in chapter 3 (C3)
50
 
@@ -227,10 +246,33 @@ static void disas_uncond_b_imm(DisasContext *s, uint32_t insn)
51
 
     gen_goto_tb(s, 0, addr);
52
 
 }
53
 
 
54
 
-/* Compare & branch (immediate) */
55
 
+/* C3.2.1 Compare & branch (immediate)
56
 
+ *   31  30         25  24  23                  5 4      0
57
 
+ * +----+-------------+----+---------------------+--------+
58
 
+ * | sf | 0 1 1 0 1 0 | op |         imm19       |   Rt   |
59
 
+ * +----+-------------+----+---------------------+--------+
60
 
+ */
61
 
 static void disas_comp_b_imm(DisasContext *s, uint32_t insn)
62
 
 {
63
 
-    unsupported_encoding(s, insn);
64
 
+    unsigned int sf, op, rt;
65
 
+    uint64_t addr;
66
 
+    int label_match;
67
 
+    TCGv_i64 tcg_cmp;
68
 
+
69
 
+    sf = extract32(insn, 31, 1);
70
 
+    op = extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */
71
 
+    rt = extract32(insn, 0, 5);
72
 
+    addr = s->pc + sextract32(insn, 5, 19) * 4 - 4;
73
 
+
74
 
+    tcg_cmp = read_cpu_reg(s, rt, sf);
75
 
+    label_match = gen_new_label();
76
 
+
77
 
+    tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ,
78
 
+                        tcg_cmp, 0, label_match);
79
 
+
80
 
+    gen_goto_tb(s, 0, s->pc);
81
 
+    gen_set_label(label_match);
82
 
+    gen_goto_tb(s, 1, addr);
83
 
 }
84
 
 
85
 
 /* C3.2.5 Test & branch (immediate)
86
 
1.8.5.2
87