Re: [Qemu-devel] [RFC] target-arm: provide skeleton for a64 insn decoding

2013-11-12 Thread Alex Bennée

claudio.font...@linaro.org writes:

 provide a skeleton for a64 instruction decoding in translate-a64.c,
 by dividing instructions into the classes defined by the
 ARM Architecture Reference Manual(DDI0487A_a) C3

 Signed-off-by: Claudio Fontana claudio.font...@linaro.org
 ---
 The following patch has been started during Linaro Connect
 by me and Alex Bennee.
snip

With the proviso of Richard's decode comment you can add:

Reviewed-by: Alex Bennée a...@bennee.com
Signed-of-by: Alex Bennée a...@bennee.com

-- 
Alex Bennée




[Qemu-devel] [RFC] target-arm: provide skeleton for a64 insn decoding

2013-11-11 Thread Claudio Fontana
provide a skeleton for a64 instruction decoding in translate-a64.c,
by dividing instructions into the classes defined by the
ARM Architecture Reference Manual(DDI0487A_a) C3

Signed-off-by: Claudio Fontana claudio.font...@linaro.org
---
The following patch has been started during Linaro Connect
by me and Alex Bennee.
The goal is to provide a decoder that is easy to match against
the ARM Architecture Reference Manual.
The plan here is a process of cleaning up / refactoring the SuSE
patchset.
 
We will be posting actual instruction implementations in the
following days and weeks.

However, as we currently have between 60-120 patches in the
backlog we thought it would be worth getting the basic decoding
skeleton agreed (and merged?) first to reduce any patch
ordering problems and ease the reviewing burden.

The first set of instruction patches will be based on
Alexander Graf's 60 patch set after we have applied fixes,
review comments and run some instruction testing using
Peter Maydell's risu tool patched for aarch64:

https://github.com/hw-claudio/risu-aarch64.git (master)

We hope from there to quickly progress through the rest of
the SUSE patch-set for getting a functional aarch64 linux-user
setup before turning our attention to system emulation.

 target-arm/translate-a64.c | 367 -
 1 file changed, 359 insertions(+), 8 deletions(-)

diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index f120088..7105728 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -107,17 +107,345 @@ static void gen_exception_insn(DisasContext *s, int 
offset, int excp)
 s-is_jmp = DISAS_JUMP;
 }
 
-static void real_unallocated_encoding(DisasContext *s)
+static void unallocated_encoding(DisasContext *s)
 {
-fprintf(stderr, Unknown instruction: %#x\n, s-insn);
 gen_exception_insn(s, 4, EXCP_UDEF);
 }
 
-#define unallocated_encoding(s) do { \
-fprintf(stderr, unallocated encoding at line: %d\n, __LINE__); \
-real_unallocated_encoding(s); \
-} while (0)
+#define unsupported_encoding(s, insn)\
+do { \
+qemu_log_mask(LOG_UNIMP,\
+  %s:%d: unsupported instruction encoding 0x%08x, \
+  __FILE__, __LINE__, insn);\
+unallocated_encoding(s);\
+} while (0);
 
+/*
+ * the instruction disassembly implemented here matches
+ * the instruction encoding classifications in chapter 3 (C3)
+ * of the ARM Architecture Reference Manual (DDI0487A_a)
+ */
+
+/* Unconditional branch (immediate) */
+static void disas_uncond_b_imm(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Compare  branch (immediate) */
+static void disas_comp_b_imm(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Test  branch (immediate) */
+static void disas_test_b_imm(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Conditional branch (immediate) */
+static void disas_cond_b_imm(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* System */
+static void disas_sys(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Exception generation */
+static void disas_exc(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Unconditional branch (register) */
+static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* C3.2 Branches, exception generating and system instructions */
+static void disas_b_exc_sys(DisasContext *s, uint32_t insn)
+{
+switch (extract32(insn, 25, 7)) {
+case 0x0a: case 0x4a: /* Unconditional branch (immediate) */
+disas_uncond_b_imm(s, insn);
+break;
+case 0x1a: case 0x5a: /* Compare  branch (immediate) */
+disas_comp_b_imm(s, insn);
+break;
+case 0x1b: case 0x5b: /* Test  branch (immediate) */
+disas_test_b_imm(s, insn);
+break;
+case 0x2a: /* Conditional branch (immediate) */
+disas_cond_b_imm(s, insn);
+break;
+case 0x6a: /* Exception generation / System */
+if (insn  (1  24)) {
+disas_sys(s, insn);
+} else {
+disas_exc(s, insn);
+}
+break;
+case 0x6b: /* Unconditional branch (register) */
+disas_uncond_b_reg(s, insn);
+break;
+default:
+unallocated_encoding(s);
+break;
+}
+}
+
+/* Load/store exclusive */
+static void disas_ldst_excl(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Load register (literal) */
+static void disas_ld_lit(DisasContext *s, uint32_t insn)
+{
+unsupported_encoding(s, insn);
+}
+
+/* Load/store pair (all forms) */
+static void 

Re: [Qemu-devel] [RFC] target-arm: provide skeleton for a64 insn decoding

2013-11-11 Thread Richard Henderson
On 11/12/2013 01:13 AM, Claudio Fontana wrote:
 +/* C3.2 Branches, exception generating and system instructions */
 +static void disas_b_exc_sys(DisasContext *s, uint32_t insn)
 +{
 +switch (extract32(insn, 25, 7)) {
 +case 0x0a: case 0x4a: /* Unconditional branch (immediate) */
 +disas_uncond_b_imm(s, insn);
 +break;

Bit 25 is - for unconditional branch, so this entry should be

 0x0a, 0x0b, 0x4a, 0x4b

All of the other decodings look good.


r~