From patchwork Tue Oct 15 17:51:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176396 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6239729ill; Tue, 15 Oct 2019 10:53:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPpetkO6kLN+MMT9xdK5Dp9/5Mqu47xVyJ9lzb6Vnazwu90OrJqsdgPqD/GDBoCIisP6oU X-Received: by 2002:a37:883:: with SMTP id 125mr36049768qki.478.1571162035334; Tue, 15 Oct 2019 10:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571162035; cv=none; d=google.com; s=arc-20160816; b=XIL/H/krt3DvPYYl3xtEks0Z87qfQKvYcc4P+0bXHqNcoLLM0cUoa4AgJ30DqmDFbe 7Ss7mSP1eTQRU9VHFYYfzopgQNEK+4xYa3c2PO6zT1W25QPnaNoi9Bz0PRyXq2v/KPsX dM+7QXLsc+2OY/PARmBuOGJ+NUb/29pXaU59Yawjic18745NTE0Kn/W2xlCUqQli670y fMlw83U6g9sH8gb4VybFmYq1l4eTiCsUUlu00mZOtyqxtIU5H2L7N9CVZ9WgXDZ0JfZT hTl8qBMtGUY+gRAT7IxIjfqgdMbZITGpXkGsQUzte7zUfjf6lVY1NEq6FT+MLr+w7WwT Lxyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1C7c6L0AKcXy94kRypeBSB6XHbsCm+dRfwVNJ4dwo8Q=; b=Gna6q7arwgfamPdeObfiFPNVSv0SopUtlipefYw0ZXdXxKbwv4IdSU7MHWttvmHhzN InGIaIQgyfgiwzp8Z0X3Xq1PFOBdBxG5+IkJxLKN72NCH4D6XqwCHRbMBaZu3w00cp0S /ubKNWQo1YtbiwQxSCNlM2JuR5f2RJJIL2LyZCEtVxagPuwxxdk5/td2X0DJe3TGYJjY olmnVgyqagQrvH4yONHM9daFkHOKFi/ozDkUfV4xafa5KuCRU3CNAkDDG+s9K/GlIaTf wsYpXD3kQki2hnhzybVrtx6OAv4qN5QusWI8NmuXIFXySsZNNx89Edwymn8WJ6gi++bJ ozDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gj+Y+3dA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d19si21850280qte.152.2019.10.15.10.53.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2019 10:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gj+Y+3dA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKR18-00072G-Na for patch@linaro.org; Tue, 15 Oct 2019 13:53:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54596) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKQyy-0004wl-JM for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKQyw-0003PV-Gj for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:40 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:35828) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKQyw-0003PH-AH for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:38 -0400 Received: by mail-pg1-x544.google.com with SMTP id p30so12592805pgl.2 for ; Tue, 15 Oct 2019 10:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1C7c6L0AKcXy94kRypeBSB6XHbsCm+dRfwVNJ4dwo8Q=; b=Gj+Y+3dAOGc9dHpOy9mhXsLqGcNMj5MIDrIoxzeR1GgxkfrjmeMlA0X897dskiv2ee xrLxCmYtK2YwsYESQjAre+jDnLqp8k9nJ9N0t1qLZ7ak6StWqaXcGlyfGZoeNRtt7U2m 7gJqa9ScHJxsD4KNYTobWED2saHsYVwogmfgEDKZiean4+RfEK1h6Y8ulDC2o9SZfskQ FJJRHMP2lNlcH+jT1vkdCpTSE++ZQU+BCvGztqyJAR5NrtPZUunXgFEv2oTXQZDj3JP0 GlSLSFNk1pSq1vVQ/C6enhK8e2o1HzjbL0wu4KCgzAHttRhONvy1de0NhlI0JyzBrx19 pqVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1C7c6L0AKcXy94kRypeBSB6XHbsCm+dRfwVNJ4dwo8Q=; b=DFUgDkqZBcW1wPjadyMvc70ai6yHDTRMDUGIZClSmIU3yTHacTzyxefxBKtgCsJhSi fcRmfT3/04SRUXBP8Lb+fUsMXN8naVF89lNizYaNBGscINx5QCj52GbYKKfQpGtjJPXk WVJVvLI/GBgKeaOepOXhesKRCQ6fLKmCgai1xWS7d1ZPOZqgoniD0WQnA4+/E3ptMABu 3NAgatttBDEB6Q//Nv5shvRRecl7Z4caasOuunMhxAs5mEWzYhgoTkCZfhMLrlBGoZ+F CJYz+3qDPmvgdrdW11ntuvfRpS5jy1e3IzJ8TArH0Pl6+PWQ1LDiecXfguSiHqxghGuy cD/Q== X-Gm-Message-State: APjAAAWRiVixb/fRhjoawhQzrDoXUPJR2Xmirao1PIR2qFo16tvEeBGJ 1dRP1TQvxmbVIUZ7gwABhcWEpYxjChA= X-Received: by 2002:a17:90a:1b45:: with SMTP id q63mr43578475pjq.106.1571161896902; Tue, 15 Oct 2019 10:51:36 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id t68sm20867845pgt.61.2019.10.15.10.51.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 10:51:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] capstone: Update to master Date: Tue, 15 Oct 2019 10:51:31 -0700 Message-Id: <20191015175133.16598-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191015175133.16598-1-richard.henderson@linaro.org> References: <20191015175133.16598-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Update to 418d36d695e0. Choose this over the 4.0.1 tag because master now includes the s390x z13 vector opcodes. Acked-by: David Hildenbrand Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- Makefile | 1 + capstone | 2 +- configure | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/Makefile b/Makefile index 30f0abfb42..8ce48e0342 100644 --- a/Makefile +++ b/Makefile @@ -498,6 +498,7 @@ dtc/%: .git-submodule-status # Remove all the extra -Warning flags that QEMU uses that Capstone doesn't; # no need to annoy QEMU developers with such things. CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS)) +CAP_CFLAGS += -I$(SRC_PATH)/capstone/include CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM CAP_CFLAGS += -DCAPSTONE_HAS_ARM CAP_CFLAGS += -DCAPSTONE_HAS_ARM64 diff --git a/capstone b/capstone index 22ead3e0bf..418d36d695 160000 --- a/capstone +++ b/capstone @@ -1 +1 @@ -Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf +Subproject commit 418d36d695e075955674ace5a1191b495da50f84 diff --git a/configure b/configure index 08ca4bcb46..f4f1860065 100755 --- a/configure +++ b/configure @@ -5008,7 +5008,7 @@ case "$capstone" in git_submodules="${git_submodules} capstone" fi mkdir -p capstone - QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include/capstone" if test "$mingw32" = "yes"; then LIBCAPSTONE=capstone.lib else From patchwork Tue Oct 15 17:51:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176397 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6252498ill; Tue, 15 Oct 2019 11:05:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxc4Avgq5IEUqMXgamz8tgSXypMR2kWfm9jJxBdYacFR2ccRpo83TvtkBnkDhAVd1ZEoPBs X-Received: by 2002:ae9:e20c:: with SMTP id c12mr37254881qkc.149.1571162738095; Tue, 15 Oct 2019 11:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571162738; cv=none; d=google.com; s=arc-20160816; b=KYBqosdkdWOOXnxfpQQlLs2TV5yvlxxHL6VJtZG2mHrNgndYZV1z334A1rD+v+GnQr SmKkDeLGmETWtOx+uW4mQz+azio6CnVBhloOCvFRB+K79RRrX827qWEPTrGFAh/A4Wqm LWj6PnIBheCNNTsPsYeOpIqCxQuuV7lGu1ovO4u0Ek/AibA1Fd/XJqofoRB64Duut9pK U74gAKG+6LXDA2tIY3Q/ct6WaP/UbwS5xt2deC2CL3mPcQd1K5aO13U6sLOa6mFJrxb1 IADHKgFNpLPv4KOMEKqP6VoUblmScm1d8tNM8sK+cpb7lVB2vTh29S0okBitu7t5AftD sXJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=JPcXbUefVYp1/DZorpkAXAFcmm1X6SF54kxYkRBFIog=; b=E11R/ZxFyaZQVhgpsi9owd2lN3n9517fHuLRmg+oAem57ItmE+zyRRelrr7jOgYutF njMC0C487CiDSaNH7LOyjGyoKrstY9dcXTFwKRNtXi4cS/KmKQl8SiHJmY2BCRolFjdF OijPU4yOioAYdQ+uZtH54NTF6PUHeD31K78ZMcPvIt1xDWqYkDlPn1DKVhEG7KmHxoNu h1R6LJW6ZesF+72Zxfy1fvXTEMCNQF/zkeQHvIOOuWDSdMtZzykBN/XW8d1ur2fZi5cA RX5VzuF4SqUlJ1Bhl2b814f72b7BWpCtPAQyOnzDkA97yx1TyBoyfyDDhKOiUI1biWvv 7DCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jE0orpGF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x14si20107170qvo.118.2019.10.15.11.05.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2019 11:05:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jE0orpGF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKRCT-00075o-KL for patch@linaro.org; Tue, 15 Oct 2019 14:05:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54601) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKQyy-0004x0-Ss for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKQyx-0003Qs-Ow for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:40 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKQyx-0003Pl-JL for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:39 -0400 Received: by mail-pl1-x641.google.com with SMTP id t10so9936531plr.8 for ; Tue, 15 Oct 2019 10:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=JPcXbUefVYp1/DZorpkAXAFcmm1X6SF54kxYkRBFIog=; b=jE0orpGFix6/Su5bS8NmnWMrRSuZHytmrxj+wzSa7qmgsoAmjutVGhK/6TUvJcAPu6 GVGF30gwVg/sk3zPasO9WkUNlE/H0hvgsO/2OfCiVmXtfloUX+6Npr75yxO19YY6vgIV ZHo++387ZEeNPW2SEJ6AKFfA7d+EDDsCjTNeFdyQMaZS7E0M++8+Mm9KFTYFDnZIhEs4 R2Hyx2cXdRiLqv6lPtei3/Xczq/NZIMYxM6N81UGuUKIL/i0DZGxjk9xQNv+L8GUeIWF yINR8dakDUa4I4ZKuwkDcg7V/2HAPTOzFU2aUHd1UNBqmt49koxLeMjs2qomDge3FxP+ Zuig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JPcXbUefVYp1/DZorpkAXAFcmm1X6SF54kxYkRBFIog=; b=cWjBs+EFhSB/IrYTG7O8tR7HhHZg7k4xqnCnr0JAHC5xK72sOGo5RWnRglxs++RXsv Y3M6cXfWSP2qb5uJfXQ7OZCbKdqa1JIeg0/Kq3OjrEbDr1FNCG5BjhCrzDugtOSBb35Y dE1c9icHpML8KBNUZ5seaDaPWrxc7Ba2PRpomQiBypUoS3ArefxOSDd23Z9LLy6iqv5f 8uYY71hN8USscYxWNgU/CRzHpckq1dT2kge77MesEVfWXJtRHEcervlkKw0izgGiDA5V wFzPfYXUK+vSHpMJJVfJzcQ82UYxDZY3CFaAEm0o0sV68qMeSH439f0wcZRpixgm1vUz FoVA== X-Gm-Message-State: APjAAAV5eN01hvC8CIlAJ0CQknQv1ARlRdigVxhMhN1/kSVobHRVxKdS mqH0OreHI6bXTFfZIk60GoPt2jzo4I4= X-Received: by 2002:a17:902:7e4e:: with SMTP id a14mr37242068pln.68.1571161898200; Tue, 15 Oct 2019 10:51:38 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id t68sm20867845pgt.61.2019.10.15.10.51.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 10:51:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] capstone: Enable disassembly for s390x Date: Tue, 15 Oct 2019 10:51:32 -0700 Message-Id: <20191015175133.16598-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191015175133.16598-1-richard.henderson@linaro.org> References: <20191015175133.16598-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Enable s390x, aka SYSZ, in the git submodule build. Set the capstone parameters for both s390x host and guest. Signed-off-by: Richard Henderson --- Makefile | 1 + disas.c | 3 +++ target/s390x/cpu.c | 4 ++++ 3 files changed, 8 insertions(+) -- 2.17.1 diff --git a/Makefile b/Makefile index 8ce48e0342..97e34be162 100644 --- a/Makefile +++ b/Makefile @@ -503,6 +503,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 3e2bfa572b..51c71534a3 100644 --- a/disas.c +++ b/disas.c @@ -550,6 +550,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 3abe7e80fd..44f40f1f8c 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; @@ -180,6 +181,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) From patchwork Tue Oct 15 17:51:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176395 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6239723ill; Tue, 15 Oct 2019 10:53:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpBfBIaQfB67bqJ39JGGPRhSqS6+3qjoexpBXfCqsfw3FE1a/DPw4qs1kEWJaPuU3aeZHB X-Received: by 2002:a05:620a:12c7:: with SMTP id e7mr35983244qkl.162.1571162035052; Tue, 15 Oct 2019 10:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571162035; cv=none; d=google.com; s=arc-20160816; b=0HNJABvaEQHWwxLGTUFl4tZHvdBcCA/78SFNqp4/OBNyyIhDyPbdLYqhw1BDMy2cE6 22YL+VhPy947DVbs25/ZFa6HHadwvFWPl1SpH0AF8iEojV/rfj/YgvhITUKidGbPjyR+ ZyIbEJ+1EV+Q7DEgHRNZRzQM21YOi/hHjFBWSNkWaNYFERb3I3hsCsNEo7/IRPZ4cxvo GnkKmjz6yLyQahvwDcwf2wZeUeB92vweneAzOD/OzKQ3BhNbLS6aruEAOpCtPjtXnu63 A69x/QFfFjrvDVNhuSyg2x1PBMBp60psMpOl2nPzntpv8YeYKANMoA+sP/UWV3Smjh9j D2cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=8nOrlYeU5zcIwPQAiPQrEysfQ5wBLY582fozX0r/c2U=; b=RUhCSAxiYrd56itcDSajKMRwYTcbfl+zhkZYxqqWpu2ZGiBKoX8+9yqpv9QMsvb7kd 6RUxOpC8pT3dBdWAL0tVr9jUhDFafC1m0kZq/lTe/7937gX5+6YeBUc+1P64uFKx1ENE FN1dMnF37XQPs83Kz040NoYiBiHHm/moKoG2T3DX6609z28M9ogEtCkc9qUqKlpGEqRK AVRsSsBVXgOUeqCXD/7JKsqjGIxe43QaGr83VzG+/KCtca8QrYyificuEIhjdT5qfmc1 bPWMhLiRgK4QRFKiDjA4/i4aUUS4tZDsoSQyMWwi/oH3vL/1JNNPlaw16xK/9cmgiA2o mBzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DagjfiVG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x39si21995373qtk.185.2019.10.15.10.53.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2019 10:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DagjfiVG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKR11-0006GW-GH for patch@linaro.org; Tue, 15 Oct 2019 13:53:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54617) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKQz0-0004yP-46 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKQyz-0003S9-05 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:42 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34386) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKQyy-0003Re-R0 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 13:51:40 -0400 Received: by mail-pf1-x442.google.com with SMTP id b128so12971570pfa.1 for ; Tue, 15 Oct 2019 10:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=8nOrlYeU5zcIwPQAiPQrEysfQ5wBLY582fozX0r/c2U=; b=DagjfiVGE76/S65G6eK8NIEjaJ0kab+fsDI39tEYEjw+UOlTN3hrj885V1WFlfP38O IT520qzq/QtWQgIljzWKhHGbPtD0HI6B0VllBSuKzh0Xh1CoOe8n7U/uvz0VDmuAiWRp AslcbdRu8aw+Sk3gwjaqNq/dcMkizrU62IB51iBGvlvSclIaHAMcAYUUFk7+IHVpb7ak gfTXVcdNZbq33oN3KOs3W9nwe4BpVEVyz7rUm6aeFJUH0EyJotWes2LJzukliyPqtUUV OcuUFdEXPhP0PGsAbSeZFABJOfL6EQd85QiXzLmWX2kaH299tT4F4ojB9N/fZclGAw10 039A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8nOrlYeU5zcIwPQAiPQrEysfQ5wBLY582fozX0r/c2U=; b=dLYudaMzOrCvJPwwRQgUDefMIRwOCOP84j1IoO86HgHo2EODol4VLPLxOt5MTFgZxu qNgIxoxC1CqSuQ8GlIz56Zz7DBRz0Bcmm4sw7bjQOUs4s7htOYLSLE9TF4l/eVUiB7rO SBeiuMyar7txMsLnVmSxjYNPfM/ewfn7acnPtQwWwZXyKm1NTt3w5s40zmbSdUsRK3Mk c02qBAfcabXtvYI3WiQ+2w5GzvcXfWqDgkmJsaoOgyTsH0NzcmnAl9wWKH9oOfGuyd/X F45E8PBbdbIIlHofEUQ43fdFCV2xCidnEW6A5a+qOAq/txCEMd76nfpY0uKNcDGHTDp2 YWEQ== X-Gm-Message-State: APjAAAVSSEbZ5PNV5zt+XYgYTdra5tOxwzpphNV2KoH66b82zeHO39lG 9viBJDZbbHZ6gGHngT0aPUyeAo5NRRo= X-Received: by 2002:a17:90a:8085:: with SMTP id c5mr14018255pjn.60.1571161899372; Tue, 15 Oct 2019 10:51:39 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id t68sm20867845pgt.61.2019.10.15.10.51.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 10:51:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] capstone: Add s390x skipdata callback Date: Tue, 15 Oct 2019 10:51:33 -0700 Message-Id: <20191015175133.16598-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191015175133.16598-1-richard.henderson@linaro.org> References: <20191015175133.16598-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Capstone assumes any unknown instruction is 2 bytes. Instead, use the ilen field in the first two bits of the instruction to stay in sync with the insn stream. Signed-off-by: Richard Henderson --- disas.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- 2.17.1 Reviewed-by: Thomas Huth diff --git a/disas.c b/disas.c index 51c71534a3..2a000cbeb0 100644 --- a/disas.c +++ b/disas.c @@ -178,6 +178,39 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) to share this across calls and across host vs target disassembly. */ static __thread cs_insn *cap_insn; +/* + * The capstone library always skips 2 bytes for S390X. + * This is less than ideal, since we can tell from the first two bits + * the size of the insn and thus stay in sync with the insn stream. + */ +static size_t CAPSTONE_API +cap_skipdata_s390x_cb(const uint8_t *code, size_t code_size, + size_t offset, void *user_data) +{ + size_t ilen; + + /* See get_ilen() in target/s390x/internal.h. */ + switch (code[offset] >> 6) { + case 0: + ilen = 2; + break; + case 1: + case 2: + ilen = 4; + break; + default: + ilen = 6; + break; + } + + return ilen; +} + +static const cs_opt_skipdata cap_skipdata_s390x = { + .mnemonic = ".byte", + .callback = cap_skipdata_s390x_cb +}; + /* Initialize the Capstone library. */ /* ??? It would be nice to cache this. We would need one handle for the host and one for the target. For most targets we can reset specific @@ -208,6 +241,10 @@ static cs_err cap_disas_start(disassemble_info *info, csh *handle) /* "Disassemble" unknown insns as ".byte W,X,Y,Z". */ cs_option(*handle, CS_OPT_SKIPDATA, CS_OPT_ON); + if (info->cap_arch == CS_ARCH_SYSZ) { + cs_option(*handle, CS_OPT_SKIPDATA_SETUP, + (uintptr_t)&cap_skipdata_s390x); + } /* Allocate temp space for cs_disasm_iter. */ if (cap_insn == NULL) {