From patchwork Wed Aug 8 12:39:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 143619 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp793726ljj; Wed, 8 Aug 2018 05:59:12 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxqvdTlzLZyKT9u7rO5C1ngtQYZ/VV3w891UcdLKl08nSBVfJjWDyakta1+0OOfx9s2fQIq X-Received: by 2002:a37:4951:: with SMTP id w78-v6mr2304485qka.2.1533733152434; Wed, 08 Aug 2018 05:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533733152; cv=none; d=google.com; s=arc-20160816; b=Rc+epHWSNHOxTeM7FKZ0vUvEzgv7BRSw2tWwWnZWdHAOLIjuJeUHypgZ3ezz5yHtt1 nrWnz9PRc7NG4bcxYbf4b+E2l43kRb7GfiWLHz8byrrzklbNDfpvkSfO43tZHfLPWXAD yvJfTh5mk+2K+v0IUbIbLczmErYlfp416lz1hNbj6c47wQsa/zsxnY7wqGUf0F7ZS+2V RFCZLJVkxjY1zUd1+NplsU5zWMIo9nwlt01yo+Zf34dOtBWnsJhysWX5P8lMoc1esh6g 9KlIO0XDtkaeC2b/vAbTys2TENMFqY1CNDW7bDxBWLito6SiBOjpWbyFxoQZGoD9a2un 7yaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=CWwuisMsfjYGQ/cKC9Z+UpNBVRg5gMBzktqI3FqX138=; b=XWTnp6iCl58PH4tYaqDxjrfV2GncClGlyKXlYFc9bM2ZvjvIlOqKcq5hYCQx2Mzy5a 2a1HmX+6Df2PwoPq5CVs8IFCIn5ZBAHEYIxcfXdJYvfcJnlTa90TrQxDFleu5LDb+ynX lJYlDP+VLcJA5IdNGkmIeyYHZ7hj73ghm/0noLEofLJGc+kEjO42erpncp9JDSUXkLAr p94hsVWscCAXpF4ebSXtHyauAyzs4wdoymgEo6k5tH0V8V20mT/q+i6tKJsTEDJtaO3B QdLdTTwKBgVi8wm1+pNp8xdEz7qkaX3DpUJp9V0g+gEK1ke2XE9wRxLKgfsBLeMEcm1h OsWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FfycqQRa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 77-v6si667332qkd.397.2018.08.08.05.59.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Aug 2018 05:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FfycqQRa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnO3T-0003vN-SW for patch@linaro.org; Wed, 08 Aug 2018 08:59:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnNka-0004Vt-Ag for qemu-devel@nongnu.org; Wed, 08 Aug 2018 08:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnNkX-0006qr-5c for qemu-devel@nongnu.org; Wed, 08 Aug 2018 08:39:40 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:34496) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnNkW-0006os-LN for qemu-devel@nongnu.org; Wed, 08 Aug 2018 08:39:37 -0400 Received: by mail-wm0-x234.google.com with SMTP id l2-v6so539191wme.1 for ; Wed, 08 Aug 2018 05:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CWwuisMsfjYGQ/cKC9Z+UpNBVRg5gMBzktqI3FqX138=; b=FfycqQRa3LPvdMtJa+g2wS9BPCGZhn/y8LE9swdtX+OewzCaIh8QZxLgxoMGOU9Kva xW1IuXAz+vySIw03FnsDzKAlaQ/KmgCHaTi30NOxrFz+fScBV31/0ISM/xTNNZIiLQyl 6VQWTFhsJ8MG4V9pk4Dm+/7HcWWTngafe9h9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CWwuisMsfjYGQ/cKC9Z+UpNBVRg5gMBzktqI3FqX138=; b=W8PyMxAluEgqRHF5u8YNLTPqWIOdFrEYWd0pAFkAi1Xd+Hi1mZxtkm+acOj1eNS1k4 Y9UcdEu2ZKLcbhhw/VkXjjULLk7fyMnlq7o+7URBJZroMLV8fAo5u+3crOsyMjn/rj0r ZiC/zGP6GFCMAuPtjM8udCPun66kdb+UUNtTDArDEz6zXxpZuM+cHzDgwr6X6svwk6p8 BuPtngLmTZV3xrSQQnRzhHuqzVQ35ZcWPg7d95087BuvKBlm4b/wxJ/quB+zr+etyICj mFJPcmXdyqzpyZk8GScLuokmzznXSN7k26hjsu73Ai8MfdCsmi6M/7LpVo48Ed3wpksf sOgw== X-Gm-Message-State: AOUpUlHmbrKn+XcaZVjWhUm6x3RpA6Yaz1NXG7hwFX/LM/KrPUSlf+6J TuwepHmaLkeRydG+aEF2+MLGOA== X-Received: by 2002:a1c:385:: with SMTP id 127-v6mr1826060wmd.92.1533731975471; Wed, 08 Aug 2018 05:39:35 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k4-v6sm5074519wrl.12.2018.08.08.05.39.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Aug 2018 05:39:34 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 520463E060C; Wed, 8 Aug 2018 13:39:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Wed, 8 Aug 2018 13:39:30 +0100 Message-Id: <20180808123934.17450-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [RFC PATCH 0/4] add hand-rolled fallback when capstone fails X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, richard.henderson@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Hi, While capstone is actively maintained it hasn't managed to keep up to date with newer instructions as they have been added. While these should eventually be supported we need something in the meantime. This proof-of-concept series takes advantage of the fact we already have a parser for SVE instructions. By tweaking the output of decodetree.py a little we can generate something we can plug into the assembly dump when capstone fails. Currently it is just the instruction name (as encoded in sve.decode) but extending it to include the parameters shouldn't be too hard. The plumbing into disas is a little ugly and perhaps that can be solved later with some re-factoring. So what do you think? Worth pursing or adding to the pile of cute but not ultimately mergable hacks? Alex Bennée (4): scripts/decodetree.py: add a disassembly generator (HACK!) target/arm: move decoder helpers into header target/arm: add a fallback disassemble function disas: allow capstone to defer to a fallback function on failure disas.c | 30 +++++++++++++++++++++- include/disas/bfd.h | 11 +++++++- scripts/decodetree.py | 52 +++++++++++++++++++++++++++++++++----- target/arm/Makefile.objs | 8 ++++++ target/arm/cpu.c | 4 +++ target/arm/decoder.h | 50 ++++++++++++++++++++++++++++++++++++ target/arm/disassemble.c | 22 ++++++++++++++++ target/arm/internals.h | 2 ++ target/arm/translate-sve.c | 50 +----------------------------------- 9 files changed, 172 insertions(+), 57 deletions(-) create mode 100644 target/arm/decoder.h create mode 100644 target/arm/disassemble.c -- 2.17.1