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

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu/arm64/0029-target-arm-A64-provide-skeleton-for-a64-insn-decodin.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 3e80439264f306f75173ccd5ebc6c8939521d328 Mon Sep 17 00:00:00 2001
 
2
From: Claudio Fontana <claudio.fontana@linaro.org>
 
3
Date: Tue, 17 Dec 2013 19:42:32 +0000
 
4
Subject: [PATCH 29/49] target-arm: A64: provide skeleton for a64 insn decoding
 
5
 
 
6
Provide a skeleton for a64 instruction decoding in translate-a64.c,
 
7
by dividing instructions into the classes defined by the
 
8
ARM Architecture Reference Manual(DDI0487A_a) section C3.
 
9
 
 
10
Signed-off-by: Claudio Fontana <claudio.fontana@linaro.org>
 
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
 
12
Reviewed-by: Richard Henderson <rth@twiddle.net>
 
13
---
 
14
 target-arm/translate-a64.c | 370 ++++++++++++++++++++++++++++++++++++++++++++-
 
15
 1 file changed, 362 insertions(+), 8 deletions(-)
 
16
 
 
17
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
 
18
index a713137..8e16cb1 100644
 
19
--- a/target-arm/translate-a64.c
 
20
+++ b/target-arm/translate-a64.c
 
21
@@ -146,17 +146,348 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest)
 
22
     }
 
23
 }
 
24
 
 
25
-static void real_unallocated_encoding(DisasContext *s)
 
26
+static void unallocated_encoding(DisasContext *s)
 
27
 {
 
28
-    fprintf(stderr, "Unknown instruction: %#x\n", s->insn);
 
29
     gen_exception_insn(s, 4, EXCP_UDEF);
 
30
 }
 
31
 
 
32
-#define unallocated_encoding(s) do { \
 
33
-    fprintf(stderr, "unallocated encoding at line: %d\n", __LINE__); \
 
34
-    real_unallocated_encoding(s); \
 
35
-    } while (0)
 
36
+#define unsupported_encoding(s, insn)                                    \
 
37
+    do {                                                                 \
 
38
+        qemu_log_mask(LOG_UNIMP,                                         \
 
39
+                      "%s:%d: unsupported instruction encoding 0x%08x "  \
 
40
+                      "at pc=%016" PRIx64 "\n",                          \
 
41
+                      __FILE__, __LINE__, insn, s->pc - 4);              \
 
42
+        unallocated_encoding(s);                                         \
 
43
+    } while (0);
 
44
 
 
45
+/*
 
46
+ * the instruction disassembly implemented here matches
 
47
+ * the instruction encoding classifications in chapter 3 (C3)
 
48
+ * of the ARM Architecture Reference Manual (DDI0487A_a)
 
49
+ */
 
50
+
 
51
+/* Unconditional branch (immediate) */
 
52
+static void disas_uncond_b_imm(DisasContext *s, uint32_t insn)
 
53
+{
 
54
+    unsupported_encoding(s, insn);
 
55
+}
 
56
+
 
57
+/* Compare & branch (immediate) */
 
58
+static void disas_comp_b_imm(DisasContext *s, uint32_t insn)
 
59
+{
 
60
+    unsupported_encoding(s, insn);
 
61
+}
 
62
+
 
63
+/* Test & branch (immediate) */
 
64
+static void disas_test_b_imm(DisasContext *s, uint32_t insn)
 
65
+{
 
66
+    unsupported_encoding(s, insn);
 
67
+}
 
68
+
 
69
+/* Conditional branch (immediate) */
 
70
+static void disas_cond_b_imm(DisasContext *s, uint32_t insn)
 
71
+{
 
72
+    unsupported_encoding(s, insn);
 
73
+}
 
74
+
 
75
+/* System */
 
76
+static void disas_system(DisasContext *s, uint32_t insn)
 
77
+{
 
78
+    unsupported_encoding(s, insn);
 
79
+}
 
80
+
 
81
+/* Exception generation */
 
82
+static void disas_exc(DisasContext *s, uint32_t insn)
 
83
+{
 
84
+    unsupported_encoding(s, insn);
 
85
+}
 
86
+
 
87
+/* Unconditional branch (register) */
 
88
+static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
 
89
+{
 
90
+    unsupported_encoding(s, insn);
 
91
+}
 
92
+
 
93
+/* C3.2 Branches, exception generating and system instructions */
 
94
+static void disas_b_exc_sys(DisasContext *s, uint32_t insn)
 
95
+{
 
96
+    switch (extract32(insn, 25, 7)) {
 
97
+    case 0x0a: case 0x0b:
 
98
+    case 0x4a: case 0x4b: /* Unconditional branch (immediate) */
 
99
+        disas_uncond_b_imm(s, insn);
 
100
+        break;
 
101
+    case 0x1a: case 0x5a: /* Compare & branch (immediate) */
 
102
+        disas_comp_b_imm(s, insn);
 
103
+        break;
 
104
+    case 0x1b: case 0x5b: /* Test & branch (immediate) */
 
105
+        disas_test_b_imm(s, insn);
 
106
+        break;
 
107
+    case 0x2a: /* Conditional branch (immediate) */
 
108
+        disas_cond_b_imm(s, insn);
 
109
+        break;
 
110
+    case 0x6a: /* Exception generation / System */
 
111
+        if (insn & (1 << 24)) {
 
112
+            disas_system(s, insn);
 
113
+        } else {
 
114
+            disas_exc(s, insn);
 
115
+        }
 
116
+        break;
 
117
+    case 0x6b: /* Unconditional branch (register) */
 
118
+        disas_uncond_b_reg(s, insn);
 
119
+        break;
 
120
+    default:
 
121
+        unallocated_encoding(s);
 
122
+        break;
 
123
+    }
 
124
+}
 
125
+
 
126
+/* Load/store exclusive */
 
127
+static void disas_ldst_excl(DisasContext *s, uint32_t insn)
 
128
+{
 
129
+    unsupported_encoding(s, insn);
 
130
+}
 
131
+
 
132
+/* Load register (literal) */
 
133
+static void disas_ld_lit(DisasContext *s, uint32_t insn)
 
134
+{
 
135
+    unsupported_encoding(s, insn);
 
136
+}
 
137
+
 
138
+/* Load/store pair (all forms) */
 
139
+static void disas_ldst_pair(DisasContext *s, uint32_t insn)
 
140
+{
 
141
+    unsupported_encoding(s, insn);
 
142
+}
 
143
+
 
144
+/* Load/store register (all forms) */
 
145
+static void disas_ldst_reg(DisasContext *s, uint32_t insn)
 
146
+{
 
147
+    unsupported_encoding(s, insn);
 
148
+}
 
149
+
 
150
+/* AdvSIMD load/store multiple structures */
 
151
+static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn)
 
152
+{
 
153
+    unsupported_encoding(s, insn);
 
154
+}
 
155
+
 
156
+/* AdvSIMD load/store single structure */
 
157
+static void disas_ldst_single_struct(DisasContext *s, uint32_t insn)
 
158
+{
 
159
+    unsupported_encoding(s, insn);
 
160
+}
 
161
+
 
162
+/* C3.3 Loads and stores */
 
163
+static void disas_ldst(DisasContext *s, uint32_t insn)
 
164
+{
 
165
+    switch (extract32(insn, 24, 6)) {
 
166
+    case 0x08: /* Load/store exclusive */
 
167
+        disas_ldst_excl(s, insn);
 
168
+        break;
 
169
+    case 0x18: case 0x1c: /* Load register (literal) */
 
170
+        disas_ld_lit(s, insn);
 
171
+        break;
 
172
+    case 0x28: case 0x29:
 
173
+    case 0x2c: case 0x2d: /* Load/store pair (all forms) */
 
174
+        disas_ldst_pair(s, insn);
 
175
+        break;
 
176
+    case 0x38: case 0x39:
 
177
+    case 0x3c: case 0x3d: /* Load/store register (all forms) */
 
178
+        disas_ldst_reg(s, insn);
 
179
+        break;
 
180
+    case 0x0c: /* AdvSIMD load/store multiple structures */
 
181
+        disas_ldst_multiple_struct(s, insn);
 
182
+        break;
 
183
+    case 0x0d: /* AdvSIMD load/store single structure */
 
184
+        disas_ldst_single_struct(s, insn);
 
185
+        break;
 
186
+    default:
 
187
+        unallocated_encoding(s);
 
188
+        break;
 
189
+    }
 
190
+}
 
191
+
 
192
+/* PC-rel. addressing */
 
193
+static void disas_pc_rel_adr(DisasContext *s, uint32_t insn)
 
194
+{
 
195
+    unsupported_encoding(s, insn);
 
196
+}
 
197
+
 
198
+/* Add/subtract (immediate) */
 
199
+static void disas_add_sub_imm(DisasContext *s, uint32_t insn)
 
200
+{
 
201
+    unsupported_encoding(s, insn);
 
202
+}
 
203
+
 
204
+/* Logical (immediate) */
 
205
+static void disas_logic_imm(DisasContext *s, uint32_t insn)
 
206
+{
 
207
+    unsupported_encoding(s, insn);
 
208
+}
 
209
+
 
210
+/* Move wide (immediate) */
 
211
+static void disas_movw_imm(DisasContext *s, uint32_t insn)
 
212
+{
 
213
+    unsupported_encoding(s, insn);
 
214
+}
 
215
+
 
216
+/* Bitfield */
 
217
+static void disas_bitfield(DisasContext *s, uint32_t insn)
 
218
+{
 
219
+    unsupported_encoding(s, insn);
 
220
+}
 
221
+
 
222
+/* Extract */
 
223
+static void disas_extract(DisasContext *s, uint32_t insn)
 
224
+{
 
225
+    unsupported_encoding(s, insn);
 
226
+}
 
227
+
 
228
+/* C3.4 Data processing - immediate */
 
229
+static void disas_data_proc_imm(DisasContext *s, uint32_t insn)
 
230
+{
 
231
+    switch (extract32(insn, 23, 6)) {
 
232
+    case 0x20: case 0x21: /* PC-rel. addressing */
 
233
+        disas_pc_rel_adr(s, insn);
 
234
+        break;
 
235
+    case 0x22: case 0x23: /* Add/subtract (immediate) */
 
236
+        disas_add_sub_imm(s, insn);
 
237
+        break;
 
238
+    case 0x24: /* Logical (immediate) */
 
239
+        disas_logic_imm(s, insn);
 
240
+        break;
 
241
+    case 0x25: /* Move wide (immediate) */
 
242
+        disas_movw_imm(s, insn);
 
243
+        break;
 
244
+    case 0x26: /* Bitfield */
 
245
+        disas_bitfield(s, insn);
 
246
+        break;
 
247
+    case 0x27: /* Extract */
 
248
+        disas_extract(s, insn);
 
249
+        break;
 
250
+    default:
 
251
+        unallocated_encoding(s);
 
252
+        break;
 
253
+    }
 
254
+}
 
255
+
 
256
+/* Logical (shifted register) */
 
257
+static void disas_logic_reg(DisasContext *s, uint32_t insn)
 
258
+{
 
259
+    unsupported_encoding(s, insn);
 
260
+}
 
261
+
 
262
+/* Add/subtract (extended register) */
 
263
+static void disas_add_sub_ext_reg(DisasContext *s, uint32_t insn)
 
264
+{
 
265
+    unsupported_encoding(s, insn);
 
266
+}
 
267
+
 
268
+/* Add/subtract (shifted register) */
 
269
+static void disas_add_sub_reg(DisasContext *s, uint32_t insn)
 
270
+{
 
271
+    unsupported_encoding(s, insn);
 
272
+}
 
273
+
 
274
+/* Data-processing (3 source) */
 
275
+static void disas_data_proc_3src(DisasContext *s, uint32_t insn)
 
276
+{
 
277
+    unsupported_encoding(s, insn);
 
278
+}
 
279
+
 
280
+/* Add/subtract (with carry) */
 
281
+static void disas_adc_sbc(DisasContext *s, uint32_t insn)
 
282
+{
 
283
+    unsupported_encoding(s, insn);
 
284
+}
 
285
+
 
286
+/* Conditional compare (immediate) */
 
287
+static void disas_cc_imm(DisasContext *s, uint32_t insn)
 
288
+{
 
289
+    unsupported_encoding(s, insn);
 
290
+}
 
291
+
 
292
+/* Conditional compare (register) */
 
293
+static void disas_cc_reg(DisasContext *s, uint32_t insn)
 
294
+{
 
295
+    unsupported_encoding(s, insn);
 
296
+}
 
297
+
 
298
+/* Conditional select */
 
299
+static void disas_cond_select(DisasContext *s, uint32_t insn)
 
300
+{
 
301
+    unsupported_encoding(s, insn);
 
302
+}
 
303
+
 
304
+/* Data-processing (1 source) */
 
305
+static void disas_data_proc_1src(DisasContext *s, uint32_t insn)
 
306
+{
 
307
+    unsupported_encoding(s, insn);
 
308
+}
 
309
+
 
310
+/* Data-processing (2 source) */
 
311
+static void disas_data_proc_2src(DisasContext *s, uint32_t insn)
 
312
+{
 
313
+    unsupported_encoding(s, insn);
 
314
+}
 
315
+
 
316
+/* C3.5 Data processing - register */
 
317
+static void disas_data_proc_reg(DisasContext *s, uint32_t insn)
 
318
+{
 
319
+    switch (extract32(insn, 24, 5)) {
 
320
+    case 0x0a: /* Logical (shifted register) */
 
321
+        disas_logic_reg(s, insn);
 
322
+        break;
 
323
+    case 0x0b: /* Add/subtract */
 
324
+        if (insn & (1 << 21)) { /* (extended register) */
 
325
+            disas_add_sub_ext_reg(s, insn);
 
326
+        } else {
 
327
+            disas_add_sub_reg(s, insn);
 
328
+        }
 
329
+        break;
 
330
+    case 0x1b: /* Data-processing (3 source) */
 
331
+        disas_data_proc_3src(s, insn);
 
332
+        break;
 
333
+    case 0x1a:
 
334
+        switch (extract32(insn, 21, 3)) {
 
335
+        case 0x0: /* Add/subtract (with carry) */
 
336
+            disas_adc_sbc(s, insn);
 
337
+            break;
 
338
+        case 0x2: /* Conditional compare */
 
339
+            if (insn & (1 << 11)) { /* (immediate) */
 
340
+                disas_cc_imm(s, insn);
 
341
+            } else {            /* (register) */
 
342
+                disas_cc_reg(s, insn);
 
343
+            }
 
344
+            break;
 
345
+        case 0x4: /* Conditional select */
 
346
+            disas_cond_select(s, insn);
 
347
+            break;
 
348
+        case 0x6: /* Data-processing */
 
349
+            if (insn & (1 << 30)) { /* (1 source) */
 
350
+                disas_data_proc_1src(s, insn);
 
351
+            } else {            /* (2 source) */
 
352
+                disas_data_proc_2src(s, insn);
 
353
+            }
 
354
+            break;
 
355
+        default:
 
356
+            unallocated_encoding(s);
 
357
+            break;
 
358
+        }
 
359
+        break;
 
360
+    default:
 
361
+        unallocated_encoding(s);
 
362
+        break;
 
363
+    }
 
364
+}
 
365
+
 
366
+/* C3.6 Data processing - SIMD and floating point */
 
367
+static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn)
 
368
+{
 
369
+    unsupported_encoding(s, insn);
 
370
+}
 
371
+
 
372
+/* C3.1 A64 instruction index by encoding */
 
373
 static void disas_a64_insn(CPUARMState *env, DisasContext *s)
 
374
 {
 
375
     uint32_t insn;
 
376
@@ -165,10 +496,33 @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s)
 
377
     s->insn = insn;
 
378
     s->pc += 4;
 
379
 
 
380
-    switch ((insn >> 24) & 0x1f) {
 
381
-    default:
 
382
+    switch (extract32(insn, 25, 4)) {
 
383
+    case 0x0: case 0x1: case 0x2: case 0x3: /* UNALLOCATED */
 
384
         unallocated_encoding(s);
 
385
         break;
 
386
+    case 0x8: case 0x9: /* Data processing - immediate */
 
387
+        disas_data_proc_imm(s, insn);
 
388
+        break;
 
389
+    case 0xa: case 0xb: /* Branch, exception generation and system insns */
 
390
+        disas_b_exc_sys(s, insn);
 
391
+        break;
 
392
+    case 0x4:
 
393
+    case 0x6:
 
394
+    case 0xc:
 
395
+    case 0xe:      /* Loads and stores */
 
396
+        disas_ldst(s, insn);
 
397
+        break;
 
398
+    case 0x5:
 
399
+    case 0xd:      /* Data processing - register */
 
400
+        disas_data_proc_reg(s, insn);
 
401
+        break;
 
402
+    case 0x7:
 
403
+    case 0xf:      /* Data processing - SIMD and floating point */
 
404
+        disas_data_proc_simd_fp(s, insn);
 
405
+        break;
 
406
+    default:
 
407
+        assert(FALSE); /* all 15 cases should be handled above */
 
408
+        break;
 
409
     }
 
410
 }
 
411
 
 
412
-- 
 
413
1.8.5.2
 
414