[PATCH 2/3] capstone: Enable disassembly for s390x

Richard Henderson posted 3 patches 6 years, 1 month ago
Maintainers: David Hildenbrand <david@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Richard Henderson <rth@twiddle.net>
[PATCH 2/3] capstone: Enable disassembly for s390x
Posted by Richard Henderson 6 years, 1 month ago
Enable s390x, aka SYSZ, in the git submodule build.
Set the capstone parameters for both s390x host and guest.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 Makefile           | 1 +
 disas.c            | 3 +++
 target/s390x/cpu.c | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/Makefile b/Makefile
index 12e129ac9d..df1c692ccd 100644
--- a/Makefile
+++ b/Makefile
@@ -504,6 +504,7 @@ CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
 CAP_CFLAGS += -DCAPSTONE_HAS_ARM
 CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
 CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
+CAP_CFLAGS += -DCAPSTONE_HAS_SYSZ
 CAP_CFLAGS += -DCAPSTONE_HAS_X86
 
 .PHONY: capstone/all
diff --git a/disas.c b/disas.c
index 3937da6157..845c40fca8 100644
--- a/disas.c
+++ b/disas.c
@@ -660,6 +660,9 @@ void disas(FILE *out, void *code, unsigned long size)
     print_insn = print_insn_m68k;
 #elif defined(__s390__)
     print_insn = print_insn_s390;
+    s.info.cap_arch = CS_ARCH_SYSZ;
+    s.info.cap_insn_unit = 2;
+    s.info.cap_insn_split = 6;
 #elif defined(__hppa__)
     print_insn = print_insn_hppa;
 #endif
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 625daeedd1..1734ad9c3a 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -43,6 +43,7 @@
 #include "sysemu/tcg.h"
 #endif
 #include "fpu/softfloat-helpers.h"
+#include "disas/capstone.h"
 
 #define CR0_RESET       0xE0UL
 #define CR14_RESET      0xC2000000UL;
@@ -162,6 +163,9 @@ static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
 {
     info->mach = bfd_mach_s390_64;
     info->print_insn = print_insn_s390;
+    info->cap_arch = CS_ARCH_SYSZ;
+    info->cap_insn_unit = 2;
+    info->cap_insn_split = 6;
 }
 
 static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
-- 
2.20.1


Re: [PATCH 2/3] capstone: Enable disassembly for s390x
Posted by Philippe Mathieu-Daudé 6 years, 1 month ago
On 1/3/20 10:24 PM, Richard Henderson wrote:
> Enable s390x, aka SYSZ, in the git submodule build.
> Set the capstone parameters for both s390x host and guest.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

I'm fine with this patch because I don't use the s390 disas often.
For the S390 experts, my previous analysis is here:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg667954.html

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   Makefile           | 1 +
>   disas.c            | 3 +++
>   target/s390x/cpu.c | 4 ++++
>   3 files changed, 8 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 12e129ac9d..df1c692ccd 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -504,6 +504,7 @@ CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
>   CAP_CFLAGS += -DCAPSTONE_HAS_ARM
>   CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
>   CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
> +CAP_CFLAGS += -DCAPSTONE_HAS_SYSZ
>   CAP_CFLAGS += -DCAPSTONE_HAS_X86
>   
>   .PHONY: capstone/all
> diff --git a/disas.c b/disas.c
> index 3937da6157..845c40fca8 100644
> --- a/disas.c
> +++ b/disas.c
> @@ -660,6 +660,9 @@ void disas(FILE *out, void *code, unsigned long size)
>       print_insn = print_insn_m68k;
>   #elif defined(__s390__)
>       print_insn = print_insn_s390;
> +    s.info.cap_arch = CS_ARCH_SYSZ;
> +    s.info.cap_insn_unit = 2;
> +    s.info.cap_insn_split = 6;
>   #elif defined(__hppa__)
>       print_insn = print_insn_hppa;
>   #endif
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index 625daeedd1..1734ad9c3a 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -43,6 +43,7 @@
>   #include "sysemu/tcg.h"
>   #endif
>   #include "fpu/softfloat-helpers.h"
> +#include "disas/capstone.h"
>   
>   #define CR0_RESET       0xE0UL
>   #define CR14_RESET      0xC2000000UL;
> @@ -162,6 +163,9 @@ static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
>   {
>       info->mach = bfd_mach_s390_64;
>       info->print_insn = print_insn_s390;
> +    info->cap_arch = CS_ARCH_SYSZ;
> +    info->cap_insn_unit = 2;
> +    info->cap_insn_split = 6;
>   }
>   
>   static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
>