qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Michael Matz <matz@suse.de>,
	C Fontana <claudio.fontana@linaro.org>,
	Dirk Mueller <dmueller@suse.de>,
	Laurent Desnogues <laurent.desnogues@gmail.com>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 04/60] arm: Add AArch64 disassembler stub
Date: Fri, 27 Sep 2013 02:47:58 +0200	[thread overview]
Message-ID: <1380242934-20953-5-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1380242934-20953-1-git-send-email-agraf@suse.de>

While we don't have a working disassembler for AArch64 yet, we still
don't want AArch64 code be disassembled through the old AArch32
disassembler.

So add a small disassembler stub that declares every instruction as
unsupported. This should be a good enough base to plug in a real one
later.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 disas.c             |  6 +++++-
 disas/Makefile.objs |  1 +
 disas/aarch64.c     | 31 +++++++++++++++++++++++++++++++
 include/disas/bfd.h |  1 +
 4 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 disas/aarch64.c

diff --git a/disas.c b/disas.c
index 0203ef2..5b6956e 100644
--- a/disas.c
+++ b/disas.c
@@ -150,7 +150,7 @@ bfd_vma bfd_getb16 (const bfd_byte *addr)
   return (bfd_vma) v;
 }
 
-#ifdef TARGET_ARM
+#if defined(TARGET_ARM) && !defined(TARGET_AARCH64)
 static int
 print_insn_thumb1(bfd_vma pc, disassemble_info *info)
 {
@@ -224,6 +224,8 @@ void target_disas(FILE *out, CPUArchState *env, target_ulong code,
         s.info.mach = bfd_mach_i386_i386;
     }
     print_insn = print_insn_i386;
+#elif defined(TARGET_AARCH64)
+    print_insn = print_insn_aarch64;
 #elif defined(TARGET_ARM)
     if (flags & 1) {
         print_insn = print_insn_thumb1;
@@ -464,6 +466,8 @@ void monitor_disas(Monitor *mon, CPUArchState *env,
         s.info.mach = bfd_mach_i386_i386;
     }
     print_insn = print_insn_i386;
+#elif defined(TARGET_AARCH64)
+    print_insn = print_insn_aarch64;
 #elif defined(TARGET_ARM)
     print_insn = print_insn_arm;
 #elif defined(TARGET_ALPHA)
diff --git a/disas/Makefile.objs b/disas/Makefile.objs
index 3b1e77a..55e9da4 100644
--- a/disas/Makefile.objs
+++ b/disas/Makefile.objs
@@ -13,6 +13,7 @@ common-obj-$(CONFIG_S390_DIS) += s390.o
 common-obj-$(CONFIG_SH4_DIS) += sh4.o
 common-obj-$(CONFIG_SPARC_DIS) += sparc.o
 common-obj-$(CONFIG_LM32_DIS) += lm32.o
+common-obj-$(CONFIG_ARM_DIS) += aarch64.o
 
 # TODO: As long as the TCG interpreter and its generated code depend
 # on the QEMU target, we cannot compile the disassembler here.
diff --git a/disas/aarch64.c b/disas/aarch64.c
new file mode 100644
index 0000000..13c667d
--- /dev/null
+++ b/disas/aarch64.c
@@ -0,0 +1,31 @@
+#include "disas/bfd.h"
+
+#define INSNLEN 4
+
+/* Stub disassembler for aarch64.  */
+
+int print_insn_aarch64(bfd_vma pc, struct disassemble_info *info)
+{
+    bfd_byte buffer[INSNLEN];
+    int status;
+    unsigned int size = 4;
+    uint32_t data;
+
+    /* Aarch64 instructions are always little-endian */
+    info->endian = BFD_ENDIAN_LITTLE;
+    info->bytes_per_chunk = size = INSNLEN;
+    info->display_endian = info->endian;
+
+    status = (*info->read_memory_func)(pc, buffer, size, info);
+    if (status != 0) {
+        (*info->memory_error_func)(status, pc, info);
+        return -1;
+    }
+
+    data = ldl_p(buffer);
+
+    (*info->fprintf_func)(info->stream, "\t[0x%08x] (%02x)\t.unknown",
+                          data, (data >> 24) & 0x1f);
+
+    return size;
+}
diff --git a/include/disas/bfd.h b/include/disas/bfd.h
index 803b6ef..6947e4c 100644
--- a/include/disas/bfd.h
+++ b/include/disas/bfd.h
@@ -409,6 +409,7 @@ int print_insn_crisv10          (bfd_vma, disassemble_info*);
 int print_insn_microblaze       (bfd_vma, disassemble_info*);
 int print_insn_ia64             (bfd_vma, disassemble_info*);
 int print_insn_lm32             (bfd_vma, disassemble_info*);
+int print_insn_aarch64          (bfd_vma, disassemble_info*);
 
 #if 0
 /* Fetch the disassembler for a given BFD, if that support is available.  */
-- 
1.7.12.4

  parent reply	other threads:[~2013-09-27  0:49 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27  0:47 [Qemu-devel] [PATCH 00/60] AArch64 TCG emulation support Alexander Graf
2013-09-27  0:47 ` [Qemu-devel] [PATCH 01/60] arm: Use symbolic device names for vfp cmp Alexander Graf
2013-09-27  0:47 ` [Qemu-devel] [PATCH 02/60] arm: Give the fpscr rounding modes names Alexander Graf
2013-09-27  0:47 ` [Qemu-devel] [PATCH 03/60] arm: Split VFP cmp from FPSCR setting Alexander Graf
2013-09-27 14:05   ` Richard Henderson
2013-09-27 22:38     ` Richard Henderson
2013-09-27  0:47 ` Alexander Graf [this message]
2013-09-27 14:07   ` [Qemu-devel] [PATCH 04/60] arm: Add AArch64 disassembler stub Richard Henderson
2013-09-27  0:47 ` [Qemu-devel] [PATCH 05/60] softfloat: Add stubs for int16 conversion Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 06/60] AArch64: Add set_pc cpu method Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 07/60] ARM: Add 64bit VFP handling Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 08/60] AArch64: Add support to print VFP registers in CPU Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 09/60] AArch64: Add b and bl handling Alexander Graf
2013-09-27  9:11   ` Claudio Fontana
2013-09-27 14:40   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 10/60] AArch64: Add handling for br instructions Alexander Graf
2013-09-27 14:51   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 11/60] AArch64: Add STP instruction emulation Alexander Graf
2013-09-27 17:38   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 12/60] AArch64: Add ldarx style " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 13/60] AArch64: Add stubs for a64 specific helpers Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 14/60] AArch64: Add orr instruction emulation Alexander Graf
2013-09-27 18:25   ` Richard Henderson
2013-10-31  0:29     ` Alexander Graf
2013-10-31  1:44       ` Peter Maydell
2013-11-18 10:15     ` Claudio Fontana
2013-11-18 10:37       ` Laurent Desnogues
2013-11-18 13:12       ` Michael Matz
2013-11-18 13:15         ` Peter Maydell
2013-11-18 13:24           ` Claudio Fontana
2013-11-18 13:46           ` Michael Matz
2013-11-18 13:49             ` Peter Maydell
2013-11-18 13:43         ` Claudio Fontana
2013-11-18 13:44           ` Peter Maydell
2013-11-18 13:55           ` Michael Matz
2013-11-18 19:51             ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 15/60] AArch64: Add add instruction family emulation Alexander Graf
2013-09-27 18:51   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 16/60] AArch64: Add emulation for SIMD ld/st multiple Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 17/60] AArch64: Add dup GPR->Vec instruction emulation Alexander Graf
2013-09-27 18:55   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 18/60] AArch64: Add umov " Alexander Graf
2013-09-27 18:56   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 19/60] AArch64: Add ins GPR->Vec " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 20/60] AArch64: Add SIMD ORR family " Alexander Graf
2013-09-27 19:21   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 21/60] AArch64: Convert SIMD load/store to common function Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 22/60] AArch64: Add AdvSIMD scalar three same group handling Alexander Graf
2013-09-27 19:24   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 23/60] AArch64: Add AdvSIMD modified immediate " Alexander Graf
2013-11-19 20:23   ` Janne Grunau
2013-09-27  0:48 ` [Qemu-devel] [PATCH 24/60] AArch64: Add SIMD ushll instruction emulation Alexander Graf
2013-09-27 19:29   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 25/60] AArch64: Add SIMD shl " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 26/60] AArch64: Add ADR " Alexander Graf
2013-11-19 17:17   ` Claudio Fontana
2013-11-19 17:52     ` Claudio Fontana
2013-11-19 18:03       ` Peter Maydell
2013-11-19 18:09         ` Peter Maydell
2013-11-20 14:40     ` Michael Matz
2013-09-27  0:48 ` [Qemu-devel] [PATCH 27/60] AArch64: Add addi " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 28/60] AArch64: Add movi " Alexander Graf
2013-09-27 19:38   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 29/60] AArch64: Add orri " Alexander Graf
2013-09-27 19:42   ` Richard Henderson
2013-11-26 11:56     ` Claudio Fontana
2013-11-26 12:05       ` Laurent Desnogues
2013-11-27 21:56       ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 30/60] AArch64: Add extr " Alexander Graf
2013-09-27 19:45   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 31/60] AArch64: Add bfm family " Alexander Graf
2013-09-27 20:01   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 32/60] AArch64: Add svc " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 33/60] AArch64: Add bc " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 34/60] AArch64: Add b.cond " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 35/60] AArch64: Add mrs " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 36/60] AArch64: Add msr " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 37/60] AArch64: Add hint " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 38/60] AArch64: Add stub barrier " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 39/60] AArch64: Add stub sys " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 40/60] AArch64: Add tbz " Alexander Graf
2013-09-27 20:50   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 41/60] AArch64: Add ldr/str instruction family emulation Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 42/60] AArch64: Add literal ld instruction emulation Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 43/60] AArch64: Add cinc " Alexander Graf
2013-09-27 20:52   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 44/60] AArch64: Add division instruction family emulation Alexander Graf
2013-09-27 20:54   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 45/60] AArch64: Add shift " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 46/60] AArch64: Add rev " Alexander Graf
2013-09-27 21:07   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 47/60] AArch64: Add clz instruction emulation Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 48/60] AArch64: Add 0x1a encoding of add instructions Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 49/60] AArch64: Add "Data-processing (3 source)" instruction Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 50/60] AArch64: Add "Floating-point<->fixed-point Alexander Graf
2013-11-19 20:41   ` Janne Grunau
2013-11-20 14:47     ` Michael Matz
2013-11-21 12:34       ` Janne Grunau
2013-11-21 12:40         ` Peter Maydell
2013-09-27  0:48 ` [Qemu-devel] [PATCH 51/60] AArch64: Add fmov (scalar, immediate) instruction Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 52/60] AArch64: Add "Floating-point<->integer conversions" Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 53/60] AArch64: Add "Floating-point compare" instruction Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 54/60] AArch64: Add "Floating-point data-processing (1 Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 55/60] " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 56/60] AArch64: Add "Floating-point data-processing (2 Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 57/60] " Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 58/60] AArch64: Add "ADD (vector)" instruction emulation Alexander Graf
2013-09-27  0:48 ` [Qemu-devel] [PATCH 59/60] AArch64: Add "Floating-point data-processing (3 Alexander Graf
2013-09-27 21:34   ` Richard Henderson
2013-09-27  0:48 ` [Qemu-devel] [PATCH 60/60] " Alexander Graf
2013-09-27  1:02 ` [Qemu-devel] [PATCH 00/60] AArch64 TCG emulation support Alexander Graf
2013-09-27  2:30   ` Peter Maydell
2013-09-27 10:39     ` Alexander Graf
2013-10-16 19:54 ` Edgar E. Iglesias
2013-10-17 12:23   ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380242934-20953-5-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=christoffer.dall@linaro.org \
    --cc=claudio.fontana@linaro.org \
    --cc=dmueller@suse.de \
    --cc=laurent.desnogues@gmail.com \
    --cc=matz@suse.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).