From nobody Wed Feb 11 00:55:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1578086793; cv=none; d=zohomail.com; s=zohoarc; b=R9cL9K7zrh9nsrO3Rbe3+vdJX2sWR2cYfABwndSmvpsUJwRi3G+pVE9DiQTHtl4xN9oZv3PBFGRG05opQIy5ibDhsqz4XdKm4oiO74XLA3+YDfP0bmeRxgiVwYr8FpReK1ejLmNdqPdcYaFTpF2tN/FeFLBUuUZ4FZ0WAcGiogM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578086793; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ezOCrOe9hJhnEdtaNkFzyuT77XDmRMIs13qAk5OKeOQ=; b=E6plctbcCkHdpxNXl+iF0Mx6FcN1MBWDzH7Wjed88aBD8pAQwQMuDzzPrWbBpUxm/67uAUN4e81QyTR0ZPwqQc47goD/xYDF9Rw/ZxpLKR2nrCOb6IHXlV+VuZ17f3pgllIHLwgilu7ZithBITSkR8i2ANbQmwdCeAeu/NzvZOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578086793670870.1884518350013; Fri, 3 Jan 2020 13:26:33 -0800 (PST) Received: from localhost ([::1]:56936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inUSm-000705-Aw for importer@patchew.org; Fri, 03 Jan 2020 16:26:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45732) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inURY-0005dZ-Ne for qemu-devel@nongnu.org; Fri, 03 Jan 2020 16:25:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1inURX-0004Vi-Im for qemu-devel@nongnu.org; Fri, 03 Jan 2020 16:25:16 -0500 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:50527) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1inURX-0004Sm-Ce for qemu-devel@nongnu.org; Fri, 03 Jan 2020 16:25:15 -0500 Received: by mail-pj1-x1044.google.com with SMTP id r67so5038701pjb.0 for ; Fri, 03 Jan 2020 13:25:15 -0800 (PST) Received: from localhost.localdomain (59-100-211-22.bri.static-ipl.aapt.com.au. [59.100.211.22]) by smtp.gmail.com with ESMTPSA id c15sm16668907pja.30.2020.01.03.13.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 13:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ezOCrOe9hJhnEdtaNkFzyuT77XDmRMIs13qAk5OKeOQ=; b=l2V1EPSqXv8APxdZ3nsWqQml9JGluP+SiH2zOM6zEiWfAlQ2O6/UQ6jvFiN8nayImp LfjbnX3sCxCQGsoKugCwrQsOeJ05av76/Nr8Wu7CBo6AWLjCCwTbthKumTQyDaAUBQZc AZ5qwktC4KVdWKTfuhdQnAI4zv3GoCROh1QORYhqn/SjefoKVzq83krQgGY9DVlNBnVx 48yR3Io2W72cOI9/JuVJYfzYNDl/L71MXAt5L2I/aoG5Nj5ubxPjn38yNucoj3iUQjDi NKzuUUch/ZMaJu0SMMZAe8B5hSVkVkxWPXWFa8IZUysUAlYDSvaEDA5Aqlcesegs87Lz rz+w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ezOCrOe9hJhnEdtaNkFzyuT77XDmRMIs13qAk5OKeOQ=; b=kom4pjGznRB7OqbLu79CqV9SN4ilW6ncpTSSakHecRlyOnTPStR3Xit/2Gjb4EjriC gCP1ednGvXgRJ0PrfhbFHXlC/nMbiSVNMu8J/pzF6M3NvN/WUWqVLDK13fpUpLMrr4gH ySAzrDFkiOIj2cJMKDKHaygaikpWvB3/v2annfCKYPspPTWvNO5aXdyhHg8WN0KQmVuN gW0mTTQzZ+alkOP/bY0bsODKBnPKHlO1xYs3C1rcUi2kS5jxpm5csAxQZtodZqWt0ylU eiBDVlruym2Ep7TBSZQb8ufWd3noe3imqqsDDq2o5Lu7awDEYCRCns+Bf3OZF8oZ8dYf PyiA== X-Gm-Message-State: APjAAAW9EZHjdpQ2C2ZfNs9BPvP4nsHaY/pKtw1yycSScP3ebe4RqTQl GAE68upv+j/HRMUBVB7jpbqY/dtJdIW0yA== X-Google-Smtp-Source: APXvYqxl0zi2oyNOAOnqzMwOF+5nqfWRrcGO+05ER8+ZcCqtUqbpw9BOM1+4YRUA2J/fsz6dvK+F3g== X-Received: by 2002:a17:902:9a8d:: with SMTP id w13mr72737703plp.40.1578086714024; Fri, 03 Jan 2020 13:25:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/3] capstone: Add skipdata hook for s390x Date: Sat, 4 Jan 2020 07:25:00 +1000 Message-Id: <20200103212500.14384-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200103212500.14384-1-richard.henderson@linaro.org> References: <20200103212500.14384-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1044 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: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Capstone assumes any s390x 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. Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- disas.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/disas.c b/disas.c index 845c40fca8..1095bad049 100644 --- a/disas.c +++ b/disas.c @@ -178,6 +178,39 @@ static int print_insn_od_target(bfd_vma pc, disassembl= e_info *info) to share this across calls and across host vs target disassembly. */ static __thread cs_insn *cap_insn; =20 +/* + * 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 =3D 2; + break; + case 1: + case 2: + ilen =3D 4; + break; + default: + ilen =3D 6; + break; + } + + return ilen; +} + +static const cs_opt_skipdata cap_skipdata_s390x =3D { + .mnemonic =3D ".byte", + .callback =3D 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) =20 /* "Disassemble" unknown insns as ".byte W,X,Y,Z". */ cs_option(*handle, CS_OPT_SKIPDATA, CS_OPT_ON); + if (info->cap_arch =3D=3D CS_ARCH_SYSZ) { + cs_option(*handle, CS_OPT_SKIPDATA_SETUP, + (uintptr_t)&cap_skipdata_s390x); + } =20 /* Allocate temp space for cs_disasm_iter. */ if (cap_insn =3D=3D NULL) { --=20 2.20.1