From patchwork Sun Oct 22 00:46:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116614 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3186404qgn; Sat, 21 Oct 2017 17:48:42 -0700 (PDT) X-Received: by 10.55.75.75 with SMTP id y72mr12572233qka.118.1508633322326; Sat, 21 Oct 2017 17:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633322; cv=none; d=google.com; s=arc-20160816; b=LkausG3RrkL72R2d7I47Lr5ZgKO3thVTvwEU46ezRDv5H7gawGJmOVyCP5jUevaT1c xprJfWfewvjcvAkL8hfMaZwKL7zmZZHYbxhemoocD4SFXf/NxdKvkv5rmrVZ1aeokHQH whUVexctP6R8dnL849S0VI1BH4K/7aVaFxA7iQi4V8bxBEa+J3CkF2+/YbEQAKKHG4jJ fMB/XPq9CcbUwBjr2DDev8Fb7Cf8yU0QYYzooX2biJxS/3XEWMgwNy2AeJTT8LXhX8o8 pryr+m3d1XmiMFKlnZIlsTuYE6qqsuQ1UuA4x2bZk1l8wSXJwmI0371AvliTKlvV/iJ3 ELGA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=w7Kv3Mjj9TYN9jK4kGmJ5g448sR6XB+ndT9VGyn5yL99LQtVdpuTMlrVjLSg+D0O6m XwZFYuyrpQVXJLq3kbotXq4eWv8un6vqItaL/TBsMubX9G1h1G/c20mll0DRAt0EQYQs u1nFLo9m7nEf+PVcLG/gWq8Wkcf2Cl7xBsPQlhptzQVcTLuOa+iQhllGaeUpdpN5pMHW WcPaUbfYjGh6HWVzOt7+XqrrmL0HIfWJ9idUc29GFkuKIBB7du9IkukcToy1G9BdYIcY Hp9nFfUZrTsAqByGbQugBDwTu8iBz6r3WA7upzRJKwjQ3AFO0hLqUD5gCb90KUd+vF75 U4WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NgBdClXf; 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 k7si1432196qtk.393.2017.10.21.17.48.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:48:42 -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=NgBdClXf; 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]:59627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64RU-0003K8-6U for patch@linaro.org; Sat, 21 Oct 2017 20:48:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PP-0002CP-I6 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PM-0008BO-1T for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:31 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:52923) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PL-0008AV-Pe for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:27 -0400 Received: by mail-pg0-x241.google.com with SMTP id a192so9196645pge.9 for ; Sat, 21 Oct 2017 17:46:27 -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=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=NgBdClXfMiZhUhLG3252Mzr3xBfd+zOTm0YhR9qe/WrnNaE3yXTA3DRxutX4NF+UwD 5+gy9njZ4PUWx9xjfY5PYVNptkjsXM+eE3Xcg2l2EwKlXUDlJC0skQhJT4I6bbY+J/cG UMRQFISW8rQe667Or6XE/lDqiV4O1t4yqrgE8= 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=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=E2ReZSexD6pTtrzT2a1nBgWjjNnFF3tzqQmprPKjq6ezzIxaUn7Ox+XSaP3FZZeGgn TMB0/lYfb7mhXE12Oh6yvvuC465cayv9LDBaue0cvPAD0629CmmOfKm7+mJk5CNn7Svs rfbaj2LfnQk8lc08aT8Yo2xYEMLv8p1O/BDvCE//5dO9pNSibz5iCosLmrC4CZxk00DF RZb6h/CrHBoLDn5fEFKew8XtXJEO5xaF4TKcdOpjE42Ck7tcJx0IDQA4F1Lepuppd3ya AkcAB944MDqfOxsPxOIal4zoYbPUXiYWyN39X9CF1pMa8aiMW8BGzrxD3+fjxQ0wgdXR t8Kg== X-Gm-Message-State: AMCzsaWJVMsoWdECMdxu/OBi3Nm6eQq66GWk2co2e+yZidMnLGYeT5vW VYWqlq1RvBrALCqIA6f9/BYKjtOso48= X-Google-Smtp-Source: ABhQp+T43ffrPSHcOCqffESU4u5fVZzkCfizhnnL4o1TkKAQxTdnp3pxyfAyDFTxlrBYVbJQk4IgHg== X-Received: by 10.98.189.23 with SMTP id a23mr1570220pff.124.1508633186415; Sat, 21 Oct 2017 17:46:26 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:11 -0700 Message-Id: <20171022004621.28372-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c05::241 Subject: [Qemu-devel] [PATCH v7 01/11] target/i386: Convert to disas_set_info hook 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 22 ++-------------------- monitor.c | 21 --------------------- target/i386/cpu.c | 12 ++++++++++++ target/i386/translate.c | 8 +------- 4 files changed, 15 insertions(+), 48 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 54eea3f9c9..7e22a80da6 100644 --- a/disas.c +++ b/disas.c @@ -204,16 +204,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_I386) - if (flags == 2) { - s.info.mach = bfd_mach_x86_64; - } else if (flags == 1) { - s.info.mach = bfd_mach_i386_i8086; - } else { - s.info.mach = bfd_mach_i386_i386; - } - s.info.print_insn = print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if ((flags >> 16) & 1) { s.info.endian = BFD_ENDIAN_LITTLE; } @@ -389,16 +380,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_I386) - if (flags == 2) { - s.info.mach = bfd_mach_x86_64; - } else if (flags == 1) { - s.info.mach = bfd_mach_i386_i8086; - } else { - s.info.mach = bfd_mach_i386_i386; - } - s.info.print_insn = print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if (flags & 0xFFFF) { /* If we have a precise definition of the instruction set, use it. */ s.info.mach = flags & 0xFFFF; diff --git a/monitor.c b/monitor.c index fe0d1bdbb4..a736ae9a81 100644 --- a/monitor.c +++ b/monitor.c @@ -1310,27 +1310,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (format == 'i') { int flags = 0; -#ifdef TARGET_I386 - CPUArchState *env = mon_get_cpu_env(); - if (wsize == 2) { - flags = 1; - } else if (wsize == 4) { - flags = 0; - } else { - /* as default we use the current CS size */ - flags = 0; - if (env) { -#ifdef TARGET_X86_64 - if ((env->efer & MSR_EFER_LMA) && - (env->segs[R_CS].flags & DESC_L_MASK)) - flags = 2; - else -#endif - if (!(env->segs[R_CS].flags & DESC_B_MASK)) - flags = 1; - } - } -#endif #ifdef TARGET_PPC CPUArchState *env = mon_get_cpu_env(); flags = msr_le << 16; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 98732cd65f..13b2f8fbc5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4097,6 +4097,17 @@ static bool x86_cpu_has_work(CPUState *cs) !(env->hflags & HF_SMM_MASK)); } +static void x86_disas_set_info(CPUState *cs, disassemble_info *info) +{ + X86CPU *cpu = X86_CPU(cs); + CPUX86State *env = &cpu->env; + + info->mach = (env->hflags & HF_CS64_MASK ? bfd_mach_x86_64 + : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 + : bfd_mach_i386_i8086); + info->print_insn = print_insn_i386; +} + static Property x86_cpu_properties[] = { #ifdef CONFIG_USER_ONLY /* apic_id = 0 by default for *-user, see commit 9886e834 */ @@ -4216,6 +4227,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) #endif cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->disas_set_info = x86_disas_set_info; dc->user_creatable = true; } diff --git a/target/i386/translate.c b/target/i386/translate.c index 5f24a2de3c..69a87de83b 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8557,15 +8557,9 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); - int disas_flags = !dc->code32; qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); -#ifdef TARGET_X86_64 - if (dc->code64) { - disas_flags = 2; - } -#endif - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, disas_flags); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); } static const TranslatorOps i386_tr_ops = { From patchwork Sun Oct 22 00:46:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116613 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3185598qgn; Sat, 21 Oct 2017 17:47:04 -0700 (PDT) X-Received: by 10.237.60.3 with SMTP id t3mr13204154qte.138.1508633224126; Sat, 21 Oct 2017 17:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633224; cv=none; d=google.com; s=arc-20160816; b=Ryho1Hx439eeJFY4PH4vZSv7BaFN847ormrNAfESsnH3PWGMRUiPr+Ja2rvlZL2pe3 twtQol8dD809n6Si445h8E0Ezgt2kS3Ya4RCKbif762U2yTNMCPBxk2xgIQT0qL6Pxdj oFZadGfC2YxIRY6gmIfFPvmyiE0YkleRN5mRHVBYWc7h4lto0tMCGGTIo1omMDtcHq2C E48wq0YpT6Gh4xlJKCfnP7flwm4M21SDYt6CXQzoTJE4N1kern0sbQqF3/Zh+quqm8Oh K6mW68bK51lk2ZLSny0LHz9om0UG5kjVA/78xS8J3P7mWIbED06izJXS3xpURUlkAQLS sX8w== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=CJ+Klme0UU2d4qc2nYxOlvPgvgN20QgVvspi6VdHzvem+O+BLoX5jEiYR7g/i+QfD4 F/Ze40tH7WQNatvDi2did/89o1R/0TvDTgY6SDrwBMinxowd38HF9ZpjWySjXXUk2w8Q NoCjisBe2ZqXBb/NTd1xAu2ncUOH5MBEDEDue2Eglx1v4iRqzAHedu0bUk7YctccSDke ZCVmKW9cN5ABfBtZcW7yFL9MPM3ZU2/+hgxmSmI2YOAkgsxObuwWOxPzZi20Wpi1olOS pHt4ydgJ6t3IPt8154JYrrjZZ2zGYWv/5l0uap1ApxpIfIuUdKS07bBLnMKjRx9D1RA1 yPTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GxS0bhIv; 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 q28si3585796qtj.171.2017.10.21.17.47.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:47:04 -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=GxS0bhIv; 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]:59623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Pu-0002E8-0H for patch@linaro.org; Sat, 21 Oct 2017 20:47:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PP-0002CQ-IB for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PN-0008Cv-DB for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:31 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:54795) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PN-0008C2-5J for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:29 -0400 Received: by mail-pg0-x241.google.com with SMTP id l24so9199298pgu.11 for ; Sat, 21 Oct 2017 17:46:29 -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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=GxS0bhIvaa67xDx0KAGSoKsTy5eNUrLwCZrtEMPAp2qJEis45wklF8Tc2zG26bln3c Pzi1CGzoA/1wXz3llpexZUISucdcF9kL8FusforJnSZyNpGjzVxY8v2nNNt8CgB6XuM3 YTCtFC2U4BOpWee4FUjO6XvzhZ5letKKUzMBs= 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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=rtA5cVGpKdqCqgPPB+lVuL1zPFjGglJKEjYjRvHoBL8W3Veqn7NWkmAo7T7cMK0QNS FbUAhS0VdGKN2jHt5GwFolNo1lIovgJUYVGtLbHMfNxiZPJagiNyyXl/2AzkFsH9Cc2D ZwlGuXmmITLO8ZOu1hHzB236PclceWPi7IbKsQ64rgHrcSK94cgl2cGXW3gFcuOWj0lD tLFN5QBE/it7+K3IwChf/eeiF8ZiztbTcL17pHQbRMGSebv2TB2Q+mELTDR4DUxNYHCg 0ynM4VocNr/I/IdH9SRrS0cwfTgDIkK/QV/d5sbJIEMWr0XRRsv2GiThV0QkVNo/NPyT G1iQ== X-Gm-Message-State: AMCzsaUYheqmIlJQBhaTRKnPvcAa0a7cuO9po4AefGERZdvtqwwCiVGn +088x3188GYXRDPquLWDhRwLagkp+tU= X-Google-Smtp-Source: ABhQp+R7Dr/5DL0+W2y03UzLcTEm9UJy1pCrvB8AeooRTOneIWN5FZRa75KiF9fcbxi3xURM8P9H7Q== X-Received: by 10.99.131.66 with SMTP id h63mr8047974pge.156.1508633187788; Sat, 21 Oct 2017 17:46:27 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:12 -0700 Message-Id: <20171022004621.28372-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c05::241 Subject: [Qemu-devel] [PATCH v7 02/11] target/ppc: Convert to disas_set_info hook 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 33 --------------------------------- monitor.c | 5 ----- target/ppc/translate.c | 5 +---- target/ppc/translate_init.c | 21 +++++++++++++++++++++ 4 files changed, 22 insertions(+), 42 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 7e22a80da6..88d16fbd57 100644 --- a/disas.c +++ b/disas.c @@ -204,23 +204,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_PPC) - if ((flags >> 16) & 1) { - s.info.endian = BFD_ENDIAN_LITTLE; - } - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it. */ - s.info.mach = flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach = bfd_mach_ppc64; -#else - s.info.mach = bfd_mach_ppc; -#endif - } - s.info.disassembler_options = (char *)"any"; - s.info.print_insn = print_insn_ppc; -#endif if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; } @@ -380,22 +363,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_PPC) - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it. */ - s.info.mach = flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach = bfd_mach_ppc64; -#else - s.info.mach = bfd_mach_ppc; -#endif - } - if ((flags >> 16) & 1) { - s.info.endian = BFD_ENDIAN_LITTLE; - } - s.info.print_insn = print_insn_ppc; -#endif if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); diff --git a/monitor.c b/monitor.c index a736ae9a81..2164dfcc3b 100644 --- a/monitor.c +++ b/monitor.c @@ -1310,11 +1310,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (format == 'i') { int flags = 0; -#ifdef TARGET_PPC - CPUArchState *env = mon_get_cpu_env(); - flags = msr_le << 16; - flags |= env->bfd_mach; -#endif monitor_disas(mon, cs, addr, count, is_physical, flags); return; } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index a81ff69d75..cddbf92564 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7407,12 +7407,9 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - int flags; - flags = env->bfd_mach; - flags |= ctx.le_mode << 16; qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.nip - pc_start, flags); + log_target_disas(cs, pc_start, ctx.nip - pc_start, 0); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 7b9bf6a773..9b4353437a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10519,6 +10519,26 @@ static gchar *ppc_gdb_arch_name(CPUState *cs) #endif } +static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) +{ + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + + if ((env->hflags >> MSR_LE) & 1) { + info->endian = BFD_ENDIAN_LITTLE; + } + info->mach = env->bfd_mach; + if (!env->bfd_mach) { +#ifdef TARGET_PPC64 + info->mach = bfd_mach_ppc64; +#else + info->mach = bfd_mach_ppc; +#endif + } + info->disassembler_options = (char *)"any"; + info->print_insn = print_insn_ppc; +} + static Property ppc_cpu_properties[] = { DEFINE_PROP_BOOL("pre-2.8-migration", PowerPCCPU, pre_2_8_migration, false), DEFINE_PROP_BOOL("pre-2.10-migration", PowerPCCPU, pre_2_10_migration, @@ -10582,6 +10602,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->virtio_is_big_endian = ppc_cpu_is_big_endian; #endif + cc->disas_set_info = ppc_disas_set_info; dc->fw_name = "PowerPC,UNKNOWN"; } From patchwork Sun Oct 22 00:46:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116616 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3187695qgn; Sat, 21 Oct 2017 17:51:10 -0700 (PDT) X-Received: by 10.55.87.199 with SMTP id l190mr12961359qkb.30.1508633470353; Sat, 21 Oct 2017 17:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633470; cv=none; d=google.com; s=arc-20160816; b=j2WWyGYWr90M0zQNsAz1MDMSVpBQ2sA3jgL2h57W37vimAWjiffnTOI6q4bLs3saR1 G5+lcmlCgME6f/VEQUjMxHOHzx9HN4WCC4Hxo8XNBKkIdsQu9vkpS9OAd5GmbjETxfkr VFJoAE/48V0VcCKWiGF29fKDux7cs9N03qdmcvU2hk6bHYdvkXDfBRjCZnwRfzd30IZ/ /uLS2j5hgkC0WfE7IPumTCgug9bqGD9jJiospfcZFu7TDaOA/YuyKi8QDxrZLq10UrHf rlK1cijWBCr9raqx7dsaJPtQ7GJnKApnYKeV2UWmcgzhmMNfuD5dkOY8Io7+iN27NCc6 Dv/Q== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=3cRCPwJbjSlpKKvbJpiNRwCc9ag14Tc1JWpw8JTCZLI=; b=WqEBVSeM7M6Xv8rIsFnhXzjd6jU/HwN+3MwO8iNo+4Je3R48MHLIuG//pmtqMPYYgK TtGk1gK6HJ3xFzQ976yqDbFW7vMAreWQyXwT6yBMZwcr8QMhFhjbvZc1n15Ha+6O/lOA ByJwtauSFJS6peL8OwbTnhxRa21lOu9VNQXbdJ5uNyj60MONZ+VT8xjc+KuCqd6a9UQ8 lfJi4LAZg5DLimqJPO/qyPdHmug7GiOn6rflPxmLi5E7JFbCu6yP/hki1H15qGvhS8ss KU0lL5U2Nfusc+yrJGJ1D/7BINDM5PbLIOVAH3EnQDEkcDN4y72x4qwtsz/unLglx4JX bh+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LNKamPJu; 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 q11si299669qtg.56.2017.10.21.17.51.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:51:10 -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=LNKamPJu; 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]:59640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Ts-0005AF-5M for patch@linaro.org; Sat, 21 Oct 2017 20:51:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PQ-0002CR-4b for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PP-0008Eq-0w for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:32 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:48323) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PO-0008Dw-O3 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:30 -0400 Received: by mail-pg0-x242.google.com with SMTP id v78so9203667pgb.5 for ; Sat, 21 Oct 2017 17:46:30 -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=3cRCPwJbjSlpKKvbJpiNRwCc9ag14Tc1JWpw8JTCZLI=; b=LNKamPJur6fo7ZqbhG2dY4TFii4VboeBFMxLbMv5BlQ2af+7EvrkqH4hlAWhToUbdF G9S271wi6zq838jM4MbxC6pFbNemQ89i35z1bLzKyaBRH7qq4REUWPxpdOOLLVNC/WeM nznpRJP7JpmE85NhjVf+v127FZ8t3hdYYHi1M= 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=3cRCPwJbjSlpKKvbJpiNRwCc9ag14Tc1JWpw8JTCZLI=; b=J4su7szAtOcCFQB9/6ON6hachweh+dpshtxZg5UnAaDGHlpgF+hAo7fyFzBr2yD/yq oSlw+8sXKYaYbDwgtzckBwl+IUQdq1k0E3Kh/VdHBwgMUCnle1OVwCvpDpCq9dIN9c9G etykGbc/KTaiu1/wSBJr8dBS7ob2YMzNK7xeCf59QKCzLjk7pDVpI7Jg06NMq48IeIHj 5WqDn3J4LRR8lVUL2o/TQUtmvm/iIhREn5/zW3S92qqk55Qkl0p9Oa2VIhafVnjo3dri pASBQnJNcQGNvcXAXazTV+2FIhvGjqx2ioCa7RU9/9btijuY2RqYtD9uLJGkO3KNWnoX LkGQ== X-Gm-Message-State: AMCzsaW0QCVFN/Qs/2/qqT0dRXwQWVpogdtN3afI979hnyPyxqamEnbg i0+4z/MXtLfBPWGXG9IgPlyGI2fbOPA= X-Google-Smtp-Source: ABhQp+RRf+itYQ0PYkac6ofyVWvKQ55FGZUQ1aWukwupy4UujdPKimqacit9Lzn0xmgPyAdceBfDuA== X-Received: by 10.99.119.3 with SMTP id s3mr8117309pgc.172.1508633189334; Sat, 21 Oct 2017 17:46:29 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:13 -0700 Message-Id: <20171022004621.28372-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v7 03/11] target/arm: Move BE32 disassembler fixup 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Capstone disassembler has its own big-endian fixup. Doing this twice does not work, of course. Move our current fixup from target/arm/cpu.c to disas/arm.c. This makes read_memory_inner_func unused and can be removed. Signed-off-by: Richard Henderson --- include/disas/bfd.h | 7 ------- disas/arm.c | 21 ++++++++++++++++----- target/arm/cpu.c | 19 ------------------- 3 files changed, 16 insertions(+), 31 deletions(-) -- 2.13.6 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/include/disas/bfd.h b/include/disas/bfd.h index d99da68267..2852f80ed6 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -307,12 +307,6 @@ typedef struct disassemble_info { (bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info); - /* A place to stash the real read_memory_func if read_memory_func wants to - do some funky address arithmetic or similar (e.g. for ARM BE32 mode). */ - int (*read_memory_inner_func) - (bfd_vma memaddr, bfd_byte *myaddr, int length, - struct disassemble_info *info); - /* Function which should be called if we get an error that we can't recover from. STATUS is the errno value from read_memory_func and MEMADDR is the address that we were trying to read. INFO is a @@ -479,7 +473,6 @@ int generic_symbol_at_address(bfd_vma, struct disassemble_info *); (INFO).buffer_vma = 0, \ (INFO).buffer_length = 0, \ (INFO).read_memory_func = buffer_read_memory, \ - (INFO).read_memory_inner_func = NULL, \ (INFO).memory_error_func = perror_memory, \ (INFO).print_address_func = generic_print_address, \ (INFO).print_insn = NULL, \ diff --git a/disas/arm.c b/disas/arm.c index 27396dd3e1..9967c45990 100644 --- a/disas/arm.c +++ b/disas/arm.c @@ -70,6 +70,17 @@ static void floatformat_to_double (unsigned char *data, double *dest) *dest = u.f; } +static int arm_read_memory(bfd_vma memaddr, bfd_byte *b, int length, + struct disassemble_info *info) +{ + assert((info->flags & INSN_ARM_BE32) == 0 || length == 2 || length == 4); + + if ((info->flags & INSN_ARM_BE32) != 0 && length == 2) { + memaddr ^= 2; + } + return info->read_memory_func(memaddr, b, length, info); +} + /* End of qemu specific additions. */ struct opcode32 @@ -3810,7 +3821,7 @@ find_ifthen_state (bfd_vma pc, struct disassemble_info *info, return; } addr -= 2; - status = info->read_memory_func (addr, (bfd_byte *)b, 2, info); + status = arm_read_memory (addr, (bfd_byte *)b, 2, info); if (status) return; @@ -3882,7 +3893,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) info->bytes_per_chunk = size; printer = print_insn_data; - status = info->read_memory_func (pc, (bfd_byte *)b, size, info); + status = arm_read_memory (pc, (bfd_byte *)b, size, info); given = 0; if (little) for (i = size - 1; i >= 0; i--) @@ -3899,7 +3910,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) info->bytes_per_chunk = 4; size = 4; - status = info->read_memory_func (pc, (bfd_byte *)b, 4, info); + status = arm_read_memory (pc, (bfd_byte *)b, 4, info); if (little) given = (b[0]) | (b[1] << 8) | (b[2] << 16) | ((unsigned)b[3] << 24); else @@ -3915,7 +3926,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) info->bytes_per_chunk = 2; size = 2; - status = info->read_memory_func (pc, (bfd_byte *)b, 2, info); + status = arm_read_memory (pc, (bfd_byte *)b, 2, info); if (little) given = (b[0]) | (b[1] << 8); else @@ -3929,7 +3940,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) || (given & 0xF800) == 0xF000 || (given & 0xF800) == 0xE800) { - status = info->read_memory_func (pc + 2, (bfd_byte *)b, 2, info); + status = arm_read_memory (pc + 2, (bfd_byte *)b, 2, info); if (little) given = (b[0]) | (b[1] << 8) | (given << 16); else diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 88578f360e..82dad0b721 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -473,21 +473,6 @@ print_insn_thumb1(bfd_vma pc, disassemble_info *info) return print_insn_arm(pc | 1, info); } -static int arm_read_memory_func(bfd_vma memaddr, bfd_byte *b, - int length, struct disassemble_info *info) -{ - assert(info->read_memory_inner_func); - assert((info->flags & INSN_ARM_BE32) == 0 || length == 2 || length == 4); - - if ((info->flags & INSN_ARM_BE32) != 0 && length == 2) { - assert(info->endian == BFD_ENDIAN_LITTLE); - return info->read_memory_inner_func(memaddr ^ 2, (bfd_byte *)b, 2, - info); - } else { - return info->read_memory_inner_func(memaddr, b, length, info); - } -} - static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) { ARMCPU *ac = ARM_CPU(cpu); @@ -513,10 +498,6 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) info->endian = BFD_ENDIAN_BIG; #endif } - if (info->read_memory_inner_func == NULL) { - info->read_memory_inner_func = info->read_memory_func; - info->read_memory_func = arm_read_memory_func; - } info->flags &= ~INSN_ARM_BE32; if (arm_sctlr_b(env)) { info->flags |= INSN_ARM_BE32; From patchwork Sun Oct 22 00:46:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116619 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3188147qgn; Sat, 21 Oct 2017 17:52:04 -0700 (PDT) X-Received: by 10.237.52.198 with SMTP id x64mr14093917qtd.326.1508633524940; Sat, 21 Oct 2017 17:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633524; cv=none; d=google.com; s=arc-20160816; b=kBMTcjtJBxwHFLSpHQqEBhk6bvTa4U4cdPqrUCONqS1lQIInHyk/+BKcMr65iGZRWT SXkJ6+XA89GiRzTRF91fGs0a0ubzAhb59M+gbPabUUOfe7y6Pfhh3Y0H4Be9wvtmJw12 mYkTZemrev+kGjQNMVDUcrR/dkfehnhssHqqthZRCYmH9Of7aILDTuLoTdkVgluLO35Z j8bwRiBKX5U8s9B3XbomZ2+5endEc0czO+4pIofcT7uN7Kq4iOgMGfOtY0aKMtN0JlxC To7RhZZiwkUiSiM2mIeboLzjbh5dei6yTwcrAuUnrGHhF2srtCk3ilp5eDAjYHvLBpph 9ICQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=qD7w2+caXAbTiodra7apFT8LXQDHNlMyP4XJlt2Yk5g=; b=cvoxUiJyHY94ZX2MTLRzgdVf15XjdGv3ExcXxEY5NgF8XCRxGsy3Lg6oJGbjWonfBu c9dLbV3SZSJMvUISOffdPsOMsNttWGN7L7ssxX+iwcILtYuW8cZvkQa/txXtENVNns/c u+kLAmYTmwQ+uCX4SvbGEivuz6ZyvnFYG3T6dl5l9+DIBCbC1SdUzPKnGAvmwYTd/C1i NiKS31HlylL1lSVBVfxZGM2SciZMga2XBS6Lq4bGgy9nJf/FK+AZYA/nNQsAPL8C9fpr dod3eu5NXHVoPueaCpmKMoaLrsgLTLoElzV3fx7rxC8ihRtfoEu8886kHb6QoFKmcr9L 7/TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kEVbHoQn; 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 i89si3408527qtd.221.2017.10.21.17.52.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:52:04 -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=kEVbHoQn; 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]:59642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Uk-00061B-SG for patch@linaro.org; Sat, 21 Oct 2017 20:52:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PR-0002CY-5I for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PQ-0008GC-6Z for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:33 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:54106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PQ-0008FF-0P for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:32 -0400 Received: by mail-pf0-x242.google.com with SMTP id t188so14596378pfd.10 for ; Sat, 21 Oct 2017 17:46:31 -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=qD7w2+caXAbTiodra7apFT8LXQDHNlMyP4XJlt2Yk5g=; b=kEVbHoQnixnOXifntjw+gVl/2aR8DGcq446ZBMh2LNBEg8oTQwBCuMgs0MKWqbtvU6 kOmweV/6Npv3yxI6b+KiwppGKh9yY3pn/TIGP9AUBgPXN315xYFb6J6blY9hJRTJeWsD hBF1BLjFsMX1UvhjSztyEM7QXXVjvc6vRmIUM= 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=qD7w2+caXAbTiodra7apFT8LXQDHNlMyP4XJlt2Yk5g=; b=jpZSNBs4fnR7WuyJKnM8eGSC88gSksX/sNYFytxLIc2RAtXndVjjU+Cmza6xM1AZU+ ANs+gxXjaqnN54xnyURM3sH4XVd40TajWIz2wlqQdzl//7LQ8qlJ7zPi0mio6dyVZYaH kXh9jZi5HiP/MtX3uK8HB27RAp6zr6s7rGUscTeMJkXmP4FAli7Zwbulm5razLR/sftN +bePE6VC8MyLAYH+VRp+/SHt99qW9FPtB4ugjbc5bTjqARIpJyAnh2KGqCTyxcfxh+xW Eb8ATSUF1tsm/RBW8OvMq5zuDxmw8vSnPfab263wyaBMQcYQFOvwFtedfRAXkjQbmsHM t8cg== X-Gm-Message-State: AMCzsaX+9y1BMp2+KqXzy/JYzb69uAJY4vgk4opWc8MuRpQbxuEdXyhL xX4LaxO4epsGYuMjl7Fw4cxSFwUVSAA= X-Google-Smtp-Source: ABhQp+T1emoEy/xaoEt/wHCbbKgqPGqHrsxigHe6244Cfy3OA77nJ9U3/9FALW/lGcWyYZ1yDmyg2A== X-Received: by 10.101.78.201 with SMTP id w9mr8045937pgq.402.1508633190685; Sat, 21 Oct 2017 17:46:30 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:14 -0700 Message-Id: <20171022004621.28372-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v7 04/11] target/arm: Don't set INSN_ARM_BE32 for CONFIG_USER_ONLY 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This matches translator behaviour in arm_lduw_code. Fixes: https://bugs.launchpad.net/qemu/+bug/1724485 Signed-off-by: Richard Henderson --- target/arm/cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 82dad0b721..a92d86faa0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -477,6 +477,7 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) { ARMCPU *ac = ARM_CPU(cpu); CPUARMState *env = &ac->env; + bool sctlr_b; if (is_a64(env)) { /* We might not be compiled with the A64 disassembler @@ -491,7 +492,9 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) } else { info->print_insn = print_insn_arm; } - if (bswap_code(arm_sctlr_b(env))) { + + sctlr_b = arm_sctlr_b(env); + if (bswap_code(sctlr_b)) { #ifdef TARGET_WORDS_BIGENDIAN info->endian = BFD_ENDIAN_LITTLE; #else @@ -499,9 +502,11 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) #endif } info->flags &= ~INSN_ARM_BE32; - if (arm_sctlr_b(env)) { +#ifndef CONFIG_USER_ONLY + if (sctlr_b) { info->flags |= INSN_ARM_BE32; } +#endif } uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) From patchwork Sun Oct 22 00:46:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116617 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3187696qgn; Sat, 21 Oct 2017 17:51:10 -0700 (PDT) X-Received: by 10.55.59.1 with SMTP id i1mr12301552qka.99.1508633470358; Sat, 21 Oct 2017 17:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633470; cv=none; d=google.com; s=arc-20160816; b=J0rRJ0U62zlLYu0UYm2DfduOgQRjAyVu/1VCjILMSzLUMD9BGxlmg/GTVSZ374GMkO LE8t51018r2tgwWlrDVa5Sv+cdI1AXzhYYO2E37H2a8ygs7YY7Iynk4QeLooqh1CrWYv BQlvz6bd2Qz+JhSRTVTgfKPwIQmkjIfKIsYQ5RkCle3O2LNwC/kyG+Qf/ii8Bxl33pI4 AsbJpjBU70pFUaNOWuKR1d3MnJZu0KEiujFNl6vEP+YIt0uylevUCopJOvjFss+e5GUR dHIxDIMYJFU1GsVoGudLMuq7wL+oTTp0K2XeN40Rza9nZcRFWNWwPLquWXzhJb5xrGPO 3DZQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=zFsdqAbF93xXjZ/MZuq1lSQULhSBp09dXZ8KmQhthVo=; b=dZaBCEVJgMI/kiioubQKisyw0UjKXoe+V1YOeDmcEtF1R+qEwED6R5zwExhEauA6hK lYYTBqI5wugYGPgBC1BgLOWbWx5eSmpg6Ptz3L1b+4ilvoc1AiSbKheKZiQGhiD3sGK7 FO1QPUqaXkDQwH/hrTvEA7Tb4yX6VTzANA5bVR+UBZ6Jai+NylN1rjfCt0qEtDX4Is6S Z3GOcyypuKPy3TeIPXZmtZD2hcmwxKlesVpYLzVdeaph99uk9oY2p72gOuO8++5ftWrc vkVuHbhOELUvTURp9EyW2UzkiRr6v5Dgm05jj+uh3vy9Y3BcMIZSr/k4Emoip6QFXlJd KbKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DCAS7x8U; 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 u89si1709970qtd.361.2017.10.21.17.51.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:51:10 -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=DCAS7x8U; 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]:59639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Ts-00059M-3E for patch@linaro.org; Sat, 21 Oct 2017 20:51:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PT-0002DY-Rx for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PR-0008Hi-Sa for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:35 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:46261) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PR-0008H9-KK for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:33 -0400 Received: by mail-pf0-x242.google.com with SMTP id p87so14599001pfj.3 for ; Sat, 21 Oct 2017 17:46:33 -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=zFsdqAbF93xXjZ/MZuq1lSQULhSBp09dXZ8KmQhthVo=; b=DCAS7x8Um6S5s7Ozm/kBpBZJAW4DdsBUvY39u1BdH0gMiUBL7jtszMssqUiLMdu9nj BxupIO3u2iTA21Vk6jrryM4/GFZoGWF4fkgkvBld78psNOT8haiI9HDnx2AiHE/kcaMG IM4KaeYEs/AaqVAHzvQk8ELHA4sar3Vfy8ECE= 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=zFsdqAbF93xXjZ/MZuq1lSQULhSBp09dXZ8KmQhthVo=; b=Df7hhm0p7DbnonGRG5aR42PiSVdl9kpUwbOKfAKnEH5SOmoqdakyuuuowVGEy75RZJ 8qv/xni5uiU2g6JP2Fx2vgC4J7lfauLUFHq91Yp9MbOh8C5+fnS7x4eerSm0uxdnNLhy TvdQlAC9IDqdUNB1yoTXbF1mwm6oN947i72zxJnddF14u76h+Xx3/kbAyeJhJBqzFO+f sXIYDXprBOPOqdepC+DE25Xl9/GEIBEfRo5vBcTD3O/+Sj4mQb5n7KHxdpVs9cGiL+Pt wX0Ds3stb1ArJ8MkHK7oDM9KFFUeHo9pnR0KaWfOchGEcaJ3iulsYaJaWrgVd4PXNoUu WUiQ== X-Gm-Message-State: AMCzsaXHrTs3ZMbUStsQLDNv9Tu1foa/R4B81/3qKfen/Pp79iqvWImJ PRM7CZL+4KZGUNrkf02ujyPgN3SOfSA= X-Google-Smtp-Source: ABhQp+Rc008EUOVKsfEA+XzeFWYxR+yDqSFVyDbkZD6C7XlTe5AzA0xsmVJ4laemvT9xiAINuiR1uQ== X-Received: by 10.98.139.132 with SMTP id e4mr9035725pfl.172.1508633192165; Sat, 21 Oct 2017 17:46:32 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:15 -0700 Message-Id: <20171022004621.28372-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c00::242 Subject: [Qemu-devel] [PATCH v7 05/11] disas: Remove unused flags arguments 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that every target is using the disas_set_info hook, the flags argument is unused. Remove it. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/disas/disas.h | 4 ++-- include/exec/log.h | 4 ++-- disas.c | 15 ++++----------- monitor.c | 3 +-- target/alpha/translate.c | 2 +- target/arm/translate-a64.c | 3 +-- target/arm/translate.c | 3 +-- target/cris/translate.c | 3 +-- target/hppa/translate.c | 2 +- target/i386/translate.c | 2 +- target/lm32/translate.c | 2 +- target/m68k/translate.c | 2 +- target/microblaze/translate.c | 2 +- target/mips/translate.c | 2 +- target/nios2/translate.c | 2 +- target/openrisc/translate.c | 2 +- target/ppc/translate.c | 2 +- target/s390x/translate.c | 2 +- target/sh4/translate.c | 2 +- target/sparc/translate.c | 2 +- target/tricore/translate.c | 2 +- target/unicore32/translate.c | 2 +- target/xtensa/translate.c | 2 +- 23 files changed, 28 insertions(+), 39 deletions(-) -- 2.13.6 diff --git a/include/disas/disas.h b/include/disas/disas.h index e549ca24a1..4d48c13c65 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -9,10 +9,10 @@ /* Disassemble this for me please... (debugging). */ void disas(FILE *out, void *code, unsigned long size); void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size, int flags); + target_ulong size); void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flags); + target_ulong pc, int nb_insn, int is_physical); /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol(target_ulong orig_addr); diff --git a/include/exec/log.h b/include/exec/log.h index ba1c9b5682..c249307911 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -38,9 +38,9 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) #ifdef NEED_CPU_H /* disas() and target_disas() to qemu_logfile: */ static inline void log_target_disas(CPUState *cpu, target_ulong start, - target_ulong len, int flags) + target_ulong len) { - target_disas(qemu_logfile, cpu, start, len, flags); + target_disas(qemu_logfile, cpu, start, len); } static inline void log_disas(void *code, unsigned long size) diff --git a/disas.c b/disas.c index 88d16fbd57..2b26466b61 100644 --- a/disas.c +++ b/disas.c @@ -171,15 +171,9 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } -/* Disassemble this for me please... (debugging). 'flags' has the following - values: - i386 - 1 means 16 bit code, 2 means 64 bit code - ppc - bits 0:15 specify (optionally) the machine instruction set; - bit 16 indicates little endian. - other targets - unused - */ +/* Disassemble this for me please... (debugging). */ void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size, int flags) + target_ulong size) { CPUClass *cc = CPU_GET_CLASS(cpu); target_ulong pc; @@ -335,10 +329,9 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, return 0; } -/* Disassembler for the monitor. - See target_disas for a description of flags. */ +/* Disassembler for the monitor. */ void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flags) + target_ulong pc, int nb_insn, int is_physical) { CPUClass *cc = CPU_GET_CLASS(cpu); int count, i; diff --git a/monitor.c b/monitor.c index 2164dfcc3b..7a802a345e 100644 --- a/monitor.c +++ b/monitor.c @@ -1309,8 +1309,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, } if (format == 'i') { - int flags = 0; - monitor_disas(mon, cs, addr, count, is_physical, flags); + monitor_disas(mon, cs, addr, count, is_physical); return; } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index f32c95b9a1..3de369b17e 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -3048,7 +3048,7 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) static void alpha_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) { qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size, 1); + log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps alpha_tr_ops = { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a39b9d3633..fc5419df7f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11403,8 +11403,7 @@ static void aarch64_tr_disas_log(const DisasContextBase *dcbase, DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, - 4 | (bswap_code(dc->sctlr_b) ? 2 : 0)); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } const TranslatorOps aarch64_translator_ops = { diff --git a/target/arm/translate.c b/target/arm/translate.c index 4da1a4cbc6..9d31769c8d 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12371,8 +12371,7 @@ static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, - dc->thumb | (dc->sctlr_b << 1)); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps arm_translator_ops = { diff --git a/target/cris/translate.c b/target/cris/translate.c index 38a999e6f1..b1fda57c74 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3297,8 +3297,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, - env->pregs[PR_VR]); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); qemu_log_unlock(); diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 26242f4b3c..ca6a6d3372 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -3904,7 +3904,7 @@ static void hppa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) break; default: qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, tb->size, 1); + log_target_disas(cs, tb->pc, tb->size); break; } } diff --git a/target/i386/translate.c b/target/i386/translate.c index 69a87de83b..e81479a50c 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8559,7 +8559,7 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps i386_tr_ops = { diff --git a/target/lm32/translate.c b/target/lm32/translate.c index 65bc9c0bf6..a83cbdf729 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -1156,7 +1156,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("\n"); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); qemu_log_unlock(); diff --git a/target/m68k/translate.c b/target/m68k/translate.c index d738f32f9c..e1e31f622c 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5620,7 +5620,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 067b0878d6..fecc61a1ec 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1810,7 +1810,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log_lock(); qemu_log("--------------\n"); #if DISAS_GNU - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); #endif qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); diff --git a/target/mips/translate.c b/target/mips/translate.c index ac05f3aa09..7c96aff1a0 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20370,7 +20370,7 @@ done_generating: && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 54fbe898df..0d2d03d2d0 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -907,7 +907,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) && qemu_log_in_addr_range(tb->pc)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, dc->pc - tb->pc, 0); + log_target_disas(cs, tb->pc, dc->pc - tb->pc); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 112db1ad0f..99f2b463ce 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1653,7 +1653,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - log_target_disas(cs, pc_start, tb->size, 0); + log_target_disas(cs, pc_start, tb->size); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index cddbf92564..469ebeb446 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7409,7 +7409,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.nip - pc_start, 0); + log_target_disas(cs, pc_start, ctx.nip - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 6ecf764a98..1ccdb35df2 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -5972,7 +5972,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log("IN: EXECUTE %016" PRIx64 "\n", dc.ex_value); } else { qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc.pc - pc_start, 1); + log_target_disas(cs, pc_start, dc.pc - pc_start); qemu_log("\n"); } qemu_log_unlock(); diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 8db9fba26e..27067cbd30 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2347,7 +2347,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */ - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 6290705b11..e89b6227f2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5855,7 +5855,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0); + log_target_disas(cs, pc_start, last_pc + 4 - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 4e4198e887..e807500e26 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8839,7 +8839,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 6c094d59d7..f9aa248a80 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -2031,7 +2031,7 @@ done_generating: qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index d7bf07e8e6..03719ce12b 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -3250,7 +3250,7 @@ done: qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc.pc - pc_start, 0); + log_target_disas(cs, pc_start, dc.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } From patchwork Sun Oct 22 00:46:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116618 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3187752qgn; Sat, 21 Oct 2017 17:51:16 -0700 (PDT) X-Received: by 10.55.113.70 with SMTP id m67mr13747205qkc.23.1508633476898; Sat, 21 Oct 2017 17:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633476; cv=none; d=google.com; s=arc-20160816; b=l3Vl/sqM8X+t4Ih+kdGSFo68UZH5G+8bK34CD75p+O3WJ+ysiX5jn8Auxil7nOipLg yWPUdufb1C4tBOUDZMUHXTb5jZiWuUpVqgsMCbMLdQNUUmFYzGPcXeQsZQIt4k5ClmpZ Q2DLkXiAWfHxxeEfNEaFyBLt54N/3GmJLtTC+IOnxJ1fiUJbynedPGzzNNxYj+QTmVv7 V5wgqZrvU9K/7usFtt8JsLfQhfcPn9+Xlu7lvBEwdGOxzAbbMZvKI4/e170frqV/gDi/ 56tRRVjbEhGgCBn+xdHNAF85Nc8gfqxiH6Lvtg4pxOd4xTitT8F2/jqsj13kJ35Rm3CR +pWg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=F4aAPey8AjmU245/+/055qgXODoF0NmDDYVp9L2BzAc=; b=PqVJtMUIe7MIuhwpeZxEtlP5iePjHG7tsZgWDjlHr8v4/VWvQteYKH77hfn64elXWp 83qtSct6JTdnjtcSTosnzcTB/Lhao5vA1d4usB7V5hyyWjh5/tv1dU7wugOKzJ+DcqMw Mro7jLVeNMFtRDI2FoXshHs8D67vY5RPQSMzCptCvgFYPjWnq/AuV449ZnEF0UvFr3XB NRhQaB7682MJQrHUTF9CoHeP53ANo9RhK7Snutz2+cTl89VlJE7oWZi8KMcWLqjyyG0a kfMlQuJ/i7pHCXeqCKtv5Q6KFBdWc7fb3mw2v9Ym9HKfhe3P/1MH53g5nYSqHUa7kTUN uP1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=J4PBquor; 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 t15si405309qtg.216.2017.10.21.17.51.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:51:16 -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=J4PBquor; 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]:59641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Ty-0005CT-Jz for patch@linaro.org; Sat, 21 Oct 2017 20:51:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PV-0002Dl-KC for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PT-0008Jf-TA for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:37 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:55577) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PT-0008Il-Je for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:35 -0400 Received: by mail-pf0-x243.google.com with SMTP id 17so14595116pfn.12 for ; Sat, 21 Oct 2017 17:46:35 -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=F4aAPey8AjmU245/+/055qgXODoF0NmDDYVp9L2BzAc=; b=J4PBquorjdxBi6FaFoI33Yi2G6H1Pivxam1R6hNX7n+JKtKHU/9cENBDwlRKFbTy2G A+fhBz1bukxrQRW5PFQewW7jwbGP2O1OLlkSBbIBfeSa/6W9fz41ZXBPBpioKV3Jv9+d s7WemNHMJbZtNV51sKcGDDTncx32zVKHxLl/Y= 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=F4aAPey8AjmU245/+/055qgXODoF0NmDDYVp9L2BzAc=; b=j9ktE4jW+CeB9cSLREbUX41Xuq2zhFWsnjRLwFSylrsj00AuEhEZrUNRW8GkHrTcuI n/zif62QF9Z4G5HF6RgS3k9Cb1nbt+aBEvjzDy6NmIdnlOjxJphMDQ93l/bXaQdlibH+ abiDD+9oUAjrDzL/ko5RojaGNJOC0PPOykUYs8zv3Yw9eLXH0TvAU36a0j15jl17zSzh igYpno7z+2YAyZ5ec24RXHdChxMpADO+W25BvefZpcewNrHNZgiZ4aqf/yDwVz7XsKmn nO8kVQvqj9MdWS+7XnSEBiQRleXkeBnGxo2e+8bF0f2YLaFNyVKQjooHcpaHHrvkrNJq BR2Q== X-Gm-Message-State: AMCzsaXIagiox22//tL9y1dd2ILci3tXzcMKVFqopNE2DK5NhENwNQhL 9nRJpnjAmdmSlYxBNsy5oSeumacrp+g= X-Google-Smtp-Source: ABhQp+QaCcz6Na8hMdhInO9GFO8YJgCxAT0gc4RwvDhEWSYH3hindofy2tKvbOY7olXVEFj30wo9lw== X-Received: by 10.98.9.27 with SMTP id e27mr8767850pfd.284.1508633194050; Sat, 21 Oct 2017 17:46:34 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:16 -0700 Message-Id: <20171022004621.28372-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c00::243 Subject: [Qemu-devel] [PATCH v7 06/11] disas: Support the Capstone disassembler library 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If configured, prefer this over our rather dated copy of the GPLv2-only binutils. This will be especially apparent with the proposed vector extensions to TCG, as disas/i386.c does not handle AVX. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/disas/bfd.h | 4 + include/disas/capstone.h | 38 ++++++++ disas.c | 219 ++++++++++++++++++++++++++++++++++++++++++++--- configure | 26 ++++++ 4 files changed, 274 insertions(+), 13 deletions(-) create mode 100644 include/disas/capstone.h -- 2.13.6 Tested-by: Philippe Mathieu-Daudé diff --git a/include/disas/bfd.h b/include/disas/bfd.h index 2852f80ed6..1f88c9e9d5 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -371,6 +371,10 @@ typedef struct disassemble_info { /* Command line options specific to the target disassembler. */ char * disassembler_options; + /* Options for Capstone disassembly. */ + int cap_arch; + int cap_mode; + } disassemble_info; diff --git a/include/disas/capstone.h b/include/disas/capstone.h new file mode 100644 index 0000000000..84e214956d --- /dev/null +++ b/include/disas/capstone.h @@ -0,0 +1,38 @@ +#ifndef QEMU_CAPSTONE_H +#define QEMU_CAPSTONE_H 1 + +#ifdef CONFIG_CAPSTONE + +#include + +#else + +/* Just enough to allow backends to init without ifdefs. */ + +#define CS_ARCH_ARM -1 +#define CS_ARCH_ARM64 -1 +#define CS_ARCH_MIPS -1 +#define CS_ARCH_X86 -1 +#define CS_ARCH_PPC -1 +#define CS_ARCH_SPARC -1 +#define CS_ARCH_SYSZ -1 + +#define CS_MODE_LITTLE_ENDIAN 0 +#define CS_MODE_BIG_ENDIAN 0 +#define CS_MODE_ARM 0 +#define CS_MODE_16 0 +#define CS_MODE_32 0 +#define CS_MODE_64 0 +#define CS_MODE_THUMB 0 +#define CS_MODE_MCLASS 0 +#define CS_MODE_V8 0 +#define CS_MODE_MICRO 0 +#define CS_MODE_MIPS3 0 +#define CS_MODE_MIPS32R6 0 +#define CS_MODE_MIPSGP64 0 +#define CS_MODE_V9 0 +#define CS_MODE_MIPS32 0 +#define CS_MODE_MIPS64 0 + +#endif /* CONFIG_CAPSTONE */ +#endif /* QEMU_CAPSTONE_H */ diff --git a/disas.c b/disas.c index 2b26466b61..e392a2926e 100644 --- a/disas.c +++ b/disas.c @@ -6,6 +6,7 @@ #include "cpu.h" #include "disas/disas.h" +#include "disas/capstone.h" typedef struct CPUDebug { struct disassemble_info info; @@ -171,6 +172,192 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } +#ifdef CONFIG_CAPSTONE +/* Temporary storage for the capstone library. This will be alloced via + malloc with a size private to the library; thus there's no reason not + to share this across calls and across host vs target disassembly. */ +static __thread cs_insn *cap_insn; + +/* 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 + parameters via cs_option(CS_OPT_MODE, new_mode), but we cannot change + CS_ARCH_* in this way. Thus we would need to be able to close and + re-open the target handle with a different arch for the target in order + to handle AArch64 vs AArch32 mode switching. */ +static cs_err cap_disas_start(disassemble_info *info, csh *handle) +{ + cs_mode cap_mode = info->cap_mode; + cs_err err; + + cap_mode += (info->endian == BFD_ENDIAN_BIG ? CS_MODE_BIG_ENDIAN + : CS_MODE_LITTLE_ENDIAN); + + err = cs_open(info->cap_arch, cap_mode, handle); + if (err != CS_ERR_OK) { + return err; + } + + /* ??? There probably ought to be a better place to put this. */ + if (info->cap_arch == CS_ARCH_X86) { + /* We don't care about errors (if for some reason the library + is compiled without AT&T syntax); the user will just have + to deal with the Intel syntax. */ + cs_option(*handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT); + } + + /* "Disassemble" unknown insns as ".byte W,X,Y,Z". */ + cs_option(*handle, CS_OPT_SKIPDATA, CS_OPT_ON); + + /* Allocate temp space for cs_disasm_iter. */ + if (cap_insn == NULL) { + cap_insn = cs_malloc(*handle); + if (cap_insn == NULL) { + cs_close(handle); + return CS_ERR_MEM; + } + } + return CS_ERR_OK; +} + +/* Disassemble SIZE bytes at PC for the target. */ +static bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size) +{ + uint8_t cap_buf[1024]; + csh handle; + cs_insn *insn; + size_t csize = 0; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + while (1) { + size_t tsize = MIN(sizeof(cap_buf) - csize, size); + const uint8_t *cbuf = cap_buf; + + target_read_memory(pc + csize, cap_buf + csize, tsize, info); + csize += tsize; + size -= tsize; + + while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + } + + /* If the target memory is not consumed, go back for more... */ + if (size != 0) { + /* ... taking care to move any remaining fractional insn + to the beginning of the buffer. */ + if (csize != 0) { + memmove(cap_buf, cbuf, csize); + } + continue; + } + + /* Since the target memory is consumed, we should not have + a remaining fractional insn. */ + if (csize != 0) { + (*info->fprintf_func)(info->stream, + "Disassembler disagrees with translator " + "over instruction decoding\n" + "Please report this to qemu-devel@nongnu.org\n"); + } + break; + } + + cs_close(&handle); + return true; +} + +/* Disassemble SIZE bytes at CODE for the host. */ +static bool cap_disas_host(disassemble_info *info, void *code, size_t size) +{ + csh handle; + const uint8_t *cbuf; + cs_insn *insn; + uint64_t pc; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + cbuf = code; + pc = (uintptr_t)code; + + while (cs_disasm_iter(handle, &cbuf, &size, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + } + if (size != 0) { + (*info->fprintf_func)(info->stream, + "Disassembler disagrees with TCG over instruction encoding\n" + "Please report this to qemu-devel@nongnu.org\n"); + } + + cs_close(&handle); + return true; +} + +#if !defined(CONFIG_USER_ONLY) +/* Disassemble COUNT insns at PC for the target. */ +static bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) +{ + uint8_t cap_buf[32]; + csh handle; + cs_insn *insn; + size_t csize = 0; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + while (1) { + /* We want to read memory for one insn, but generically we do not + know how much memory that is. We have a small buffer which is + known to be sufficient for all supported targets. Try to not + read beyond the page, Just In Case. For even more simplicity, + ignore the actual target page size and use a 1k boundary. If + that turns out to be insufficient, we'll come back around the + loop and read more. */ + uint64_t epc = QEMU_ALIGN_UP(pc + csize + 1, 1024); + size_t tsize = MIN(sizeof(cap_buf) - csize, epc - pc); + const uint8_t *cbuf = cap_buf; + + /* Make certain that we can make progress. */ + assert(tsize != 0); + info->read_memory_func(pc, cap_buf + csize, tsize, info); + csize += tsize; + + if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + if (--count <= 0) { + break; + } + } + memmove(cap_buf, cbuf, csize); + } + + cs_close(&handle); + return true; +} +#endif /* !CONFIG_USER_ONLY */ +#else +# define cap_disas_target(i, p, s) false +# define cap_disas_host(i, p, s) false +# define cap_disas_monitor(i, p, c) false +#endif /* CONFIG_CAPSTONE */ + /* Disassemble this for me please... (debugging). */ void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size) @@ -187,6 +374,8 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, s.info.buffer_vma = code; s.info.buffer_length = size; s.info.print_address_func = generic_print_address; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -198,6 +387,10 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } + if (s.info.cap_arch >= 0 && cap_disas_target(&s.info, code, size)) { + return; + } + if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; } @@ -205,18 +398,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, for (pc = code; size > 0; pc += count, size -= count) { fprintf(out, "0x" TARGET_FMT_lx ": ", pc); count = s.info.print_insn(pc, &s.info); -#if 0 - { - int i; - uint8_t b; - fprintf(out, " {"); - for(i = 0; i < count; i++) { - target_read_memory(pc + i, &b, 1, &s.info); - fprintf(out, " %02x", b); - } - fprintf(out, " }"); - } -#endif fprintf(out, "\n"); if (count < 0) break; @@ -244,6 +425,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.buffer = code; s.info.buffer_vma = (uintptr_t)code; s.info.buffer_length = size; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef HOST_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -281,6 +464,11 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__hppa__) print_insn = print_insn_hppa; #endif + + if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) { + return; + } + if (print_insn == NULL) { print_insn = print_insn_od_host; } @@ -343,8 +531,9 @@ void monitor_disas(Monitor *mon, CPUState *cpu, monitor_disas_is_physical = is_physical; s.info.read_memory_func = monitor_read_memory; s.info.print_address_func = generic_print_address; - s.info.buffer_vma = pc; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -356,6 +545,10 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } + if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) { + return; + } + if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); diff --git a/configure b/configure index 6f21aaf989..26e5ce7787 100755 --- a/configure +++ b/configure @@ -375,6 +375,7 @@ opengl_dmabuf="no" cpuid_h="no" avx2_opt="no" zlib="yes" +capstone="" lzo="" snappy="" bzip2="" @@ -1294,6 +1295,10 @@ for opt do error_exit "vhost-user isn't available on win32" fi ;; + --disable-capstone) capstone="no" + ;; + --enable-capstone) capstone="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1541,6 +1546,7 @@ disabled with --disable-FEATURE, default is enabled if available: vxhs Veritas HyperScale vDisk backend support crypto-afalg Linux AF_ALG crypto backend driver vhost-user vhost-user support + capstone capstone disassembler support NOTE: The object files are built at the place where configure is launched EOF @@ -4411,6 +4417,22 @@ EOF fi ########################################## +# capstone + +if test "$capstone" != no; then + if $pkg_config capstone; then + capstone=yes + QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" + LIBS="$($pkg_config --libs capstone) $LIBS" + else + if test "$capstone" = yes; then + feature_not_found capstone + fi + capstone=no + fi +fi + +########################################## # check if we have fdatasync fdatasync=no @@ -5468,6 +5490,7 @@ echo "jemalloc support $jemalloc" echo "avx2 optimization $avx2_opt" echo "replication support $replication" echo "VxHS block device $vxhs" +echo "capstone $capstone" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6142,6 +6165,9 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi +if test "$capstone" = "yes" ; then + echo "CONFIG_CAPSTONE=y" >> $config_host_mak +fi # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on From patchwork Sun Oct 22 00:46:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116620 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3188149qgn; Sat, 21 Oct 2017 17:52:05 -0700 (PDT) X-Received: by 10.55.170.15 with SMTP id t15mr12221005qke.232.1508633525159; Sat, 21 Oct 2017 17:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633525; cv=none; d=google.com; s=arc-20160816; b=O3mIsE12KdSJ7zR3Wq5l7vKFm5LTeibLtWsD6rcPaHWzFZOAHrV3OVm4r5BkNxZaFw zbMdLQk9/g83AFtndHMltN/sKTnRgmqrawKo6n/ydvQAh55ZdbZQytAQU7G0Md8Bji/t VSl0fYltWC4Zbqw2JFUwnezzWja0aaO0h+Xo+0OF4EU31nEH5xcTnyngA4LiSPEA3tEy SBTk3xT2J7Wg21CBGR6H1YTIncJZvm8V9zReZqAsYHfk1Gj8MBWVH+0korauig0zEO7S 4HaBPmjGvHHatPpVIwchopmGwYcBiR7GaWgvys7yYLEx4FJM68AfQOvqHHwvmou3ykFJ O4IA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=OS3S1qBJRLjTIJMmgNCx5qlhB1Oq1JJ0wL49vtrAfst/nkvXPAB8E4kHcH1wP9/kjW oIRTG0UfI+JSutX3GvmxubRbRHFsbWlrapMn4AlPpWNKsXHZZJmgWHR/xXpFjz0m5kmp l3FjO7YYqDO4kZpUoQ6e8Jitu9uo2nWLemFPU2ai+cG/Azv6z2wYi0VtNnymPTsD33gs Oz6KHY7ZdE7HLdVR22j/lqpTWTl8hXaPBnAKXZNqFMNVormJwIiHLfVghM+g/RPMzfCg z3jo3aaYjksf0zfXJEZgwtNw4cIvsAlZUPM/tTou5FePK0bisPlf/Yzc6CMfzyY+xef3 8f/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MlC3nGiV; 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 9si1975442qtd.34.2017.10.21.17.52.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:52:05 -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=MlC3nGiV; 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]:59643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Ul-00061O-5p for patch@linaro.org; Sat, 21 Oct 2017 20:52:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PZ-0002Hh-Kd for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PU-0008Kk-V4 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PU-0008K0-Ol for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:36 -0400 Received: by mail-pg0-x241.google.com with SMTP id j3so9213592pga.1 for ; Sat, 21 Oct 2017 17:46:36 -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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=MlC3nGiVANjPjHtEsuAtl+Ekhk9mGJhHIu3ujJeV4O6AvlvQ/nPqC6CLrQImlP4AWT b0gBEHovkeRWkWs1ePOTqlnYYyHcsB1E7yn85TsNvqF1cqOzFJCKenICZF89+8XQwffW NzNkJ20Tnp0tcoNM9aweyxwElrRBkAMn4y3tw= 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=j0vEvcaz9kfjSnCNBPFOl4CwKKr/yFeVqaZ+WpxglXYDVT1wY5Q77SuGeQ1tCuYONS la2rDW2GZRFJt0jhc5KnpBEcZAVr2EQpDxBZQpOwtcXP3eDAtvf4APqvoKaVhTkSyYXW wGvhRHW6dLD30Fs7hr7/8yVzQl6vJOtvVvzMDlYTr8mwDiLliYAR/eOALa+ifv8pXNN+ Twp7kKth/LdJZpDXzHVbwAVjADAN26kERN9ua5raAXKl6BL2r+bz4b+i5J9Lcb94YNoL yR/hpMBSDb285EigDzQRzI3eaZ5ckqvGnmwKXZhF/K8ZpXVXEn2S1fVIPEV0U78vaqF1 OyPg== X-Gm-Message-State: AMCzsaXqpNBcWWNu5gH+tn4GwY52P03dYc+9USd801DT4ChSJI23tcvZ /OCdZtlWoNmdsmoqNlzWX1mEHiK8NQ4= X-Google-Smtp-Source: ABhQp+QEPKIjZI2WNflITYKAxe2VLScsGolEIefx9pSXbUZ/iUTwO00+TMoL8HED0MUMm/C76DkEFQ== X-Received: by 10.98.34.79 with SMTP id i76mr1835409pfi.42.1508633195543; Sat, 21 Oct 2017 17:46:35 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:17 -0700 Message-Id: <20171022004621.28372-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c05::241 Subject: [Qemu-devel] [PATCH v7 07/11] i386: Support Capstone in disas_set_info 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 11 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index e392a2926e..63dc573e9f 100644 --- a/disas.c +++ b/disas.c @@ -438,9 +438,13 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__i386__) s.info.mach = bfd_mach_i386_i386; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_32; #elif defined(__x86_64__) s.info.mach = bfd_mach_x86_64; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_64; #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 13b2f8fbc5..cf890b763b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -51,6 +51,8 @@ #include "hw/i386/apic_internal.h" #endif +#include "disas/capstone.h" + /* Cache topology CPUID constants: */ @@ -4106,6 +4108,11 @@ static void x86_disas_set_info(CPUState *cs, disassemble_info *info) : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 : bfd_mach_i386_i8086); info->print_insn = print_insn_i386; + + info->cap_arch = CS_ARCH_X86; + info->cap_mode = (env->hflags & HF_CS64_MASK ? CS_MODE_64 + : env->hflags & HF_CS32_MASK ? CS_MODE_32 + : CS_MODE_16); } static Property x86_cpu_properties[] = { From patchwork Sun Oct 22 00:46:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116623 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3189784qgn; Sat, 21 Oct 2017 17:55:20 -0700 (PDT) X-Received: by 10.55.95.133 with SMTP id t127mr12949810qkb.24.1508633720316; Sat, 21 Oct 2017 17:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633720; cv=none; d=google.com; s=arc-20160816; b=cqgmIMcbMzp1+qqn+FJT5cBGvkR9M2a154N6EwYbJ5nIsVCMk+pPdWI1Vyu5Tp6bfb 7cnoy+4NXlvrvWQryxki6kdVAJBLNhuzuZFIHaWscHp5s+5Rg5zfWxFMyOpSgZiX2QdK p54hY+FyMkboitD3nV9hL77fEey0Y8bem9l0vM5fYYFI+cceRhFGyGfAmgRN/uMBW7Ye Io/uDYNVrlBgTBlgc7fzZFxafkAgNYWVmuCKt9WRp1c+ijgWVfzarjblDfUIL/4rpwkY LsUEmPFRKuOS7u/CtG/gkpwJsC47Xs3MKcmpTwwuEpb14PowfBiAtyEcKvcLK5pjH8z1 74fg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=u2Eo0shySmvK/Gcanf/Kfbgx1Z+lcvn56DU+hji8jKeJ+eW6ZVwxGYc4lNc7jusbW7 FuvXdsnx2FRs+fGDn9GI5lf8JMUl4ne+vOqZK/rj9oo7DbmG9UMDwx3s433ZGQxjII4/ QfwhRIeX2KEgUTD24Qn5S8srPYsTt7afhMULpjil/oNJxpIsGqOv+89ulqXY1zfRZiBG f797jD57EUdCDZ+6OCkQQFjx3EWkX2WSEIaHOhJWF1pxAJdxyIQyXDUWG5ChfyaGylz+ wEPWKcIQA/Keyzi77/WkmXPvIyVCkKJENa+X8JeMqQJ3CZdrwENa1GZvLLz2n5ElwQOo YzRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aKuHYRg7; 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 x43si325587qtk.383.2017.10.21.17.55.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:55:20 -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=aKuHYRg7; 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]:59652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Xu-00006v-9K for patch@linaro.org; Sat, 21 Oct 2017 20:55:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PZ-0002Hw-SP for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PW-0008MP-M8 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:43776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PW-0008Lr-G5 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:38 -0400 Received: by mail-pf0-x244.google.com with SMTP id a8so14600294pfc.0 for ; Sat, 21 Oct 2017 17:46: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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=aKuHYRg77no9oflkgb5lmez626Jfh5XJnnicnadnZxY74Ad5fMyeUuhf4Os1Nb2I// 4FmI+vM6jo+bRMH4LgO/pQWzFxYr2x2kFnKLSEIwo2ch2tTSkmJ/hdg4ZU81DZJkgn02 BMMV40WjRi6YN6vF/6vS4hVlj4LDMKeZPgVOw= 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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=puCw1mpzNZm71unl9qMYhdRQSm74NjFezDARl47ijh3+jhw2XPleq+g4A7wkBdfmjR mwxm2Dqdecq21JJfsQEThEzBzFSpZ3ApQLkmm+ts3igebVKgo+HGY/ztXRn/9G4QzBcT kxPsiCzLJugmWyWm+nxqfPwgBeLz1xTNBoY4iFvIW4UIB6/Nx+w2wDb9KXMjWiEPu05+ w5aCQzWVX6OtkU3hlhFXiZXYeWQ75CTCts+ngnvfgM2HRcZrnPZn5duu47g8URaBo4Yy ZNdaXyS4sulTU55Um2ZL9AnA2gwYxqLxXRajVK3vF/WRmKKQxbJeCQUrx+l/NuzNms74 zAQg== X-Gm-Message-State: AMCzsaVZM4zzNQxDZvdjKjsUISUFTi7+pFpESoCNU7K6U1Z+YTkOGimP NP5KGBg94T7GOu/FDemQtCUfQriMGAg= X-Google-Smtp-Source: ABhQp+QB3463BnYm+8a4M7LOBu4RLU3FoLpc/udlHYi6mcQfZ1uNCrnFPX6Z4g7WmUtqYw2Kv/tCXw== X-Received: by 10.99.134.200 with SMTP id x191mr7916797pgd.86.1508633197053; Sat, 21 Oct 2017 17:46:37 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:18 -0700 Message-Id: <20171022004621.28372-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c00::244 Subject: [Qemu-devel] [PATCH v7 08/11] arm: Support Capstone in disas_set_info 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 3 +++ target/arm/cpu.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 63dc573e9f..8d9bd4901c 100644 --- a/disas.c +++ b/disas.c @@ -450,6 +450,7 @@ void disas(FILE *out, void *code, unsigned long size) print_insn = print_insn_ppc; #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; + s.info.cap_arch = CS_ARCH_ARM64; #elif defined(__alpha__) print_insn = print_insn_alpha; #elif defined(__sparc__) @@ -457,6 +458,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.mach = bfd_mach_sparc_v9b; #elif defined(__arm__) print_insn = print_insn_arm; + s.info.cap_arch = CS_ARCH_ARM; + /* TCG only generates code for arm mode. */ #elif defined(__MIPSEB__) print_insn = print_insn_big_mips; #elif defined(__MIPSEL__) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a92d86faa0..a0ed11c9a5 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -33,6 +33,7 @@ #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "kvm_arm.h" +#include "disas/capstone.h" static void arm_cpu_set_pc(CPUState *cs, vaddr value) { @@ -487,10 +488,24 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) #if defined(CONFIG_ARM_A64_DIS) info->print_insn = print_insn_arm_a64; #endif - } else if (env->thumb) { - info->print_insn = print_insn_thumb1; + info->cap_arch = CS_ARCH_ARM64; } else { - info->print_insn = print_insn_arm; + int cap_mode; + if (env->thumb) { + info->print_insn = print_insn_thumb1; + cap_mode = CS_MODE_THUMB; + } else { + info->print_insn = print_insn_arm; + cap_mode = CS_MODE_ARM; + } + if (arm_feature(env, ARM_FEATURE_V8)) { + cap_mode |= CS_MODE_V8; + } + if (arm_feature(env, ARM_FEATURE_M)) { + cap_mode |= CS_MODE_MCLASS; + } + info->cap_arch = CS_ARCH_ARM; + info->cap_mode = cap_mode; } sctlr_b = arm_sctlr_b(env); From patchwork Sun Oct 22 00:46:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116622 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3189352qgn; Sat, 21 Oct 2017 17:54:21 -0700 (PDT) X-Received: by 10.200.45.178 with SMTP id p47mr13362450qta.263.1508633661158; Sat, 21 Oct 2017 17:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633661; cv=none; d=google.com; s=arc-20160816; b=HHOCENLrLm/byw0F8zuSDAwsV1i+wvOIk258y4mTOJcS7QJ/qjiPksgTkQDR4oRn1v 1JRQMcFJlNtBJ1vPBb0Alazt8760dVW1iZ37t44+LJgHlBYhSjKgj85lPVW9B1Rr9Itj 0OC2NUiJvfb5xTpP6HD8dQ633RwbUSCbuQviA6yuo00wtQfMM9rVmogrkUDZd0JDucbV +gNMhmuh5Yi81/7GGqZlYNOxF8vyV9mo7AVWhzHdNqS0QWtXKRPmuq4O7Lyl172UWl18 64dPcXP7snmBerAXlNE5nj92G+70goMG+uvBcy+MWFj1aM2Y5mvQANBsCnpt/O7rd4jO lHfA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=jIsgRnOsFfFGoat1gMdCU1OANKqAjPBh66K5Lfnx221GyyHXt1QJlfumpTxb2sobEu sg8xoEiRKsPEdlaHyBWsOd5jTjLZSZCS8o6zBc/QLITp4J8QsKXWzd4jTSR+CRD84Xnw fDjZZTTh5by2tdtw2vxlT5LvAme2bCe9+HNZaP9TZ/0BTnq5hejvL+xXzi3qRtG3YMo2 6GlOP5EvhF/ZpNIWOZpaeZIRoSzsSmp4brvWQPRxlMLgiV457r7P+ZbrZ3cFYneM9mEN KDUBJ8ehk+4u2lmdE89fsylRo7VzMYOtp3h8V5rTL6YaCsNAGS5xnHKqfyy1VXD75evL eQJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X9OPDaAo; 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 w134si3575736qkw.38.2017.10.21.17.54.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:54:21 -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=X9OPDaAo; 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]:59651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Wx-0007oF-45 for patch@linaro.org; Sat, 21 Oct 2017 20:54:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PZ-0002Hr-Qx for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PY-0008O3-3f for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:44600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PX-0008NA-Tm for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:40 -0400 Received: by mail-pf0-x243.google.com with SMTP id x7so14605632pfa.1 for ; Sat, 21 Oct 2017 17:46:39 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=X9OPDaAo4au+pmHqcbVwcpZNPXgqcyhDqlVB68YtnChAw9hVI0PckzjI82eZdyLK+V DybhgvmNUCEDmlBcl/oh/OnPW2XEn4V6FmL6UmtitU08kWYftXHo5Kx7wVuIIU/Xgf8t EVEWrT+ZDQCSmGc1ZL9nDksnn+KozF5dL8yR8= 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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=kUPjnWq5YNDgQOqWD4AXiRCoGK76Q01ZwEVc28iq7lfh0OjjVB1gnujWbrar/WA6vg W0Q/Omzw2NU7T9AsTgeQHe2N3xRlgbRfHy+oFdmbSb3CvA7rOpRKPrvDRN/G62MzmXxs Qoq6m2yiG6nWbAoVrqR3LlmZ7dWv78nvuWNoRIuHXs+dHvf2RIFrll+vYGP4G7LSCsrO WM7WWX3ieogEdYk+Ze3WtWxruZGlQmxB/qcKrytjhlkk4NXKcx3p6JwnaGW68M4G6EAp 7arfRwrLZDxt/qvFtp0CgoHrqZXvqxzG+cE6xZY72b8orW6ji2rZiTV7SK3KeABTCymj CX7Q== X-Gm-Message-State: AMCzsaUbY3gLFnYnbRlCViaNH15Lgg3V9JHlE24AjpXU8um+7RELY1fC eJlO17TPb+zWdjK0U92CZ9BGKcRH0fs= X-Google-Smtp-Source: ABhQp+R7S38TmYK6abnoayrlSMrJQaF3sviJVD8zEPtl8QWELgNtDDJKKSYmVzNANUv/cvsVFeCC+A== X-Received: by 10.99.168.76 with SMTP id i12mr8213114pgp.427.1508633198441; Sat, 21 Oct 2017 17:46:38 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:19 -0700 Message-Id: <20171022004621.28372-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c00::243 Subject: [Qemu-devel] [PATCH v7 09/11] ppc: Support Capstone in disas_set_info 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: qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-ppc@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/ppc/translate_init.c | 6 ++++++ 2 files changed, 10 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index 8d9bd4901c..e52e776a60 100644 --- a/disas.c +++ b/disas.c @@ -448,6 +448,10 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; + s.info.cap_arch = CS_ARCH_PPC; +# ifdef _ARCH_PPC64 + s.info.cap_mode = CS_MODE_64; +# endif #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; s.info.cap_arch = CS_ARCH_ARM64; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 9b4353437a..41f46193a1 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -35,6 +35,7 @@ #include "mmu-book3s-v3.h" #include "sysemu/qtest.h" #include "qemu/cutils.h" +#include "disas/capstone.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -10537,6 +10538,11 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) } info->disassembler_options = (char *)"any"; info->print_insn = print_insn_ppc; + + info->cap_arch = CS_ARCH_PPC; +#ifdef TARGET_PPC64 + info->cap_mode = CS_MODE_64; +#endif } static Property ppc_cpu_properties[] = { From patchwork Sun Oct 22 00:46:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116621 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3189122qgn; Sat, 21 Oct 2017 17:53:50 -0700 (PDT) X-Received: by 10.55.175.132 with SMTP id y126mr13753259qke.45.1508633630351; Sat, 21 Oct 2017 17:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633630; cv=none; d=google.com; s=arc-20160816; b=toQU7HtQQcqWtlOifK1T9GDW5LV2ZOyRa09ua7ocCrmxSg/jKcmnNxs7ixIZM3x0ND HXtD0rwpmexbLtD4oydzE4pRVVJiVIiRKYMCOUxxJEv1ZIgUvQQ4YHpYaLWINMuvdsl9 Gu5D5IoxmfvKvLtl6jnVwrtZeVt9POi48+s3fhDi5QD7qx9uZCpelhhXmLiBSxr8uR/K RGbHAS068hqEbl32eRXai2s73w4OkUDQz6Clhwd4/UNEaktT0uTw3P5ms7CR2W13HRQl 8KU6A1fOrTkJMMuzI/3CepUirUfVKNr8MePA0ZFf+mk7bjm6pCTPMQuQrzrTgIL/Xdj+ 3R9w== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=Bba0EPWesF7DBlwQXJH2+pDDqlXLn4ckLp5LLlvH91vtGFSgOyLCObGGenKtEIrGEL QzYcWki8bbyViW/USpPj3iO4X0IXtTJyR0geUJE9LxzkN5uACczZ7YUerd+FNjKmFpom xWaYOrMK0f5fe9HUd0UGikcVm07BHn5qhpvbhgLOETfaFxLjYe66l63lXXgFwNduETBt 1luT7ZchgdTc+JyICLlAop8shmTgMQe8MhwB2Xb26t0LLe22dqJfPR5rCxAroND8xeFK uBGeq3MQJO11eVrkZHZx+Eb/hZO/Z3nQFD+iiYOIFlpCPbJGtt2BjSxW2loRkuQ0YxDl xyXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSopRGql; 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 d29si3605781qtc.94.2017.10.21.17.53.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:53:50 -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=aSopRGql; 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]:59648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64WS-0007E3-Am for patch@linaro.org; Sat, 21 Oct 2017 20:53:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Pa-0002Iq-MS for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PZ-0008Pe-GJ for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:42 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:51804) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PZ-0008Or-8u for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: by mail-pg0-x241.google.com with SMTP id p9so9199815pgc.8 for ; Sat, 21 Oct 2017 17:46:41 -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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=aSopRGqlWmzYhYjmLIshLCd6nkYpig5/K/tyuI0rKKda3JcC3ShBSl8C3ezGaAZgSL iDcwEhxzxh+uiFznOGA060M1VskBcu3xMbtRXwTO5V65al81Wdt+fR3OfBqoVMgOcN3L NHQTuioNXZB6sXMNSE2oS2egNLE0lFlfC6aRw= 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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=DOrBdzRd1+cVswlMQfkQp7HvCZRW8AZaR8qsQl0Ym/UMinw4xOe8Oudq041gTI8Nm3 CvHf9au0T6J/UBqFgCST3N51TRNfEglqEOoMLatMtcLRJACDSq4Lk8jMSOS/gH481ATj IZZJVomTeq8v8xWzpUSn0la/SBKq89gKzXVzVVjsCfkAd86oCaukmx5w1odvh6lPmlsh LgMJCCDXKrbEu8MaI5N+m7VtidEjBGtMUug0oAt9WxjgFtqvMaVUzb8hQhEZyutcghMB pBxIg6NUxi9p4TLIN+b4hLl1q/7YVCXjYH2s/C8iKnBD9YKFygssV3mQFztiVaL/w6IO ktKQ== X-Gm-Message-State: AMCzsaU1O997GPpbFIrX6zjxkSF7Jl47LD61oE2uVQRpRE2ciTFHw2/8 6lI0ZG8Q2K2fKQ2oP2UGmMvSp3h1cXs= X-Google-Smtp-Source: ABhQp+Tt5LqSIJtYNGCoahau6SwblHDEvkmBcFlLWvUlSl2tbZ/8FyGt1lAAruLBjn/96FS56uVftw== X-Received: by 10.99.172.83 with SMTP id z19mr8276201pgn.46.1508633200087; Sat, 21 Oct 2017 17:46:40 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:20 -0700 Message-Id: <20171022004621.28372-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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:400e:c05::241 Subject: [Qemu-devel] [PATCH v7 10/11] disas: Remove monitor_disas_is_physical 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Even though there is only one monitor, and thus no race on this global data object, there is also no point in having it. We can just as well record the decision in the read_memory_function that we select. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index e52e776a60..92b389d25f 100644 --- a/disas.c +++ b/disas.c @@ -512,19 +512,11 @@ const char *lookup_symbol(target_ulong orig_addr) #include "monitor/monitor.h" -static int monitor_disas_is_physical; - static int -monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, +physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) { - CPUDebug *s = container_of(info, CPUDebug, info); - - if (monitor_disas_is_physical) { - cpu_physical_memory_read(memaddr, myaddr, length); - } else { - cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0); - } + cpu_physical_memory_read(memaddr, myaddr, length); return 0; } @@ -539,8 +531,8 @@ void monitor_disas(Monitor *mon, CPUState *cpu, INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); s.cpu = cpu; - monitor_disas_is_physical = is_physical; - s.info.read_memory_func = monitor_read_memory; + s.info.read_memory_func + = (is_physical ? physical_read_memory : target_read_memory); s.info.print_address_func = generic_print_address; s.info.buffer_vma = pc; s.info.cap_arch = -1; From patchwork Sun Oct 22 00:46:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116624 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3190371qgn; Sat, 21 Oct 2017 17:56:41 -0700 (PDT) X-Received: by 10.55.120.194 with SMTP id t185mr12813505qkc.202.1508633801394; Sat, 21 Oct 2017 17:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633801; cv=none; d=google.com; s=arc-20160816; b=nU1C6pQyXg4MBZm69gz2i69jHD0vMDm2TgbLDoEfC9UI2Km8Dyg2uBtVVIp8z/wZum JOsHh3l7MfMJyarN7S2fbjoO4m2C/kkARp2hx8KCMSVwmyl1vMZ9cDLeNangFEX91qOg IUDVsqLDsr3Ay/glfMuMY/0exyMbsc6Vd9rX8uq8qhSrhLdHCWCJxwQaXeIDJGEIxVDH gLDGcLfWwRaGwjBsnTg/P5kG8UThn7WI6UJL9eo8+BQYma20aTkRoWg9aXOdVQfOu4Ps uOxn3x7c0VAXnGkJ66zzIkT8iFR2ZXkl+kLtCMTQPQdIeNdOBFXGSdxv2LRf+Xz5no3V rMgA== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+hVRL+bJLOVygj5VE2J7+XYckQ8VXrEnW8VFKOT4x/Q=; b=Ye2bhUM6QK9L7b6V4q58QdLGC6IA/BocQIRorjSCy6K03FVuZ+zSFiWZyvW8sqNGeI FuK2a12FdY6yy2n8F8E25Ygtj8MHfTisQHuu2aH1Y+QiX4LkEyzN3f5esAC7zmLxSARt 5OkvTab/JnxkukvmXj9NPXh5hJrJZBuVv2J3KRL4z62Ic1BOZ3HXmPiUA5we2ze6IAOR gbAGnYB/wRSSxXOzK3tbkEjn8/whUMQvQesOS8at9Xy6oIJj2QKpKKktVk/B6vSzf+ip CkTYbkGmV2nShUt7JLWYhK9YFxmvHvYGzxo3Zt5CaCspkjRetINqVWrKxpJWaMcZK4vf KOOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E8Oin8Vs; 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 b16si517301qkb.358.2017.10.21.17.56.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:56:41 -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=E8Oin8Vs; 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]:59660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64ZD-00017p-BC for patch@linaro.org; Sat, 21 Oct 2017 20:56:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Pc-0002Kg-FT for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64Pb-0008Re-4m for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:44 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:48324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64Pa-0008Qq-V2 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:43 -0400 Received: by mail-pg0-x242.google.com with SMTP id v78so9203814pgb.5 for ; Sat, 21 Oct 2017 17:46:42 -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=+hVRL+bJLOVygj5VE2J7+XYckQ8VXrEnW8VFKOT4x/Q=; b=E8Oin8VsSWP/7hNhJNjnn1s+BiGmJdGwu+AVPJcqCSZKD9PUebEu6Qios2F5p1AbAB fYsO5qJfO/GXPkiyXkbylK64LM91Teq9vX/9wDC8jmWv6aVniWEin5iD3dpZu8jPmRhU CRoiSngC/vScrMjq5mTWz2Oe1eDjFq48GobhY= 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=+hVRL+bJLOVygj5VE2J7+XYckQ8VXrEnW8VFKOT4x/Q=; b=A1wmHFQpeNkUOthZuBeYHgGXTChNKpg8S3MuO5SzsmssfH7uwdM/aotD9iMxb382zC wW1liJ0pi/2t5v66+2FJyIdSMzhNTupIzTMwrGXuyzLA+jBJCe+ZlrJHdSaHlhGpt4Nd AZNE+iGgYlM+xNwtQLvZ6FzIkJoWQ7QyfYzGPNOv609+TJmwAliwvJ0AyFnQSPdv1Zpu bHa5wFD6pj69eEUdsRM3vc9VzEjMjNIx2da89FllwRexnNpy1fBJNdU12yJECHfkrRwL g4L6cGpqlrWUrSH/KoxiO/Oj3wA9RO7OizpVjvIrvN7XVeTm4Oo035l04iTkv73xjqmW qDQA== X-Gm-Message-State: AMCzsaVsxu4YnXgcjzdnIe2NFgKPKedQImCod7XKkTZEzcaQigCD4rJx gpUztpKElHntFs+rhMgR42WrU4/tcTk= X-Google-Smtp-Source: ABhQp+Sb48dZQ0VNZYePb6fGamoeJzmAbQ4LGTYvL/Kmfb+LGKZy3Y61SIasnSgJBfuWxz0Eiw/R/g== X-Received: by 10.99.123.94 with SMTP id k30mr8158025pgn.33.1508633201655; Sat, 21 Oct 2017 17:46:41 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:21 -0700 Message-Id: <20171022004621.28372-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v7 11/11] disas: Add capstone as submodule 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not require the submodule, but use it if present. Allow the command-line to override system or git submodule either way. Signed-off-by: Richard Henderson --- Makefile | 13 +++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 66 insertions(+), 11 deletions(-) create mode 160000 capstone -- 2.13.6 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/Makefile b/Makefile index 9372742f86..beecc85bee 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,19 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests dtc/%: .git-submodule-status mkdir -p $@ +# Overriding CFLAGS causes us to lose defines added in the sub-makefile. +# Not overriding CFLAGS leads to mis-matches between compilation modes. +# Therefore we replicate some of the logic in the sub-makefile. +CAP_CFLAGS = $(subst -Werror,,$(CFLAGS) $(QEMU_CFLAGS)) +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_X86 + +subdir-capstone: .git-submodule-status + $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/libcapstone.a) + $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) diff --git a/.gitmodules b/.gitmodules index 7c981a42b6..1500579638 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "ui/keycodemapdb"] path = ui/keycodemapdb url = git://git.qemu.org/keycodemapdb.git +[submodule "capstone"] + path = capstone + url = git://git.qemu.org/capstone.git diff --git a/capstone b/capstone new file mode 160000 index 0000000000..a279481dbf --- /dev/null +++ b/capstone @@ -0,0 +1 @@ +Subproject commit a279481dbfd54bb1e2336d771e89978cc6d43176 diff --git a/configure b/configure index 26e5ce7787..2807569f9f 100755 --- a/configure +++ b/configure @@ -1299,6 +1299,10 @@ for opt do ;; --enable-capstone) capstone="yes" ;; + --enable-capstone=git) capstone="git" + ;; + --enable-capstone=system) capstone="system" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -4419,18 +4423,49 @@ fi ########################################## # capstone -if test "$capstone" != no; then - if $pkg_config capstone; then - capstone=yes +case "$capstone" in + "" | yes) + if $pkg_config capstone; then + capstone=system + elif test -e "${source_path}/.git" ; then + capstone=git + elif test -e "${source_path}/capstone/Makefile" ; then + capstone=internal + elif test -z "$capstone" ; then + capstone=no + else + feature_not_found "capstone" "Install capstone devel or git submodule" + fi + ;; + + system) + if ! $pkg_config capstone; then + feature_not_found "capstone" "Install capstone devel" + fi + ;; +esac + +case "$capstone" in + git | internal) + if test "$capstone" = git; then + git_submodules="${git_submodules} capstone" + fi + mkdir -p capstone + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + LIBS="\$(BUILD_DIR)/capstone/libcapstone.a $LIBS" + ;; + + system) QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" LIBS="$($pkg_config --libs capstone) $LIBS" - else - if test "$capstone" = yes; then - feature_not_found capstone - fi - capstone=no - fi -fi + ;; + + no) + ;; + *) + error_exit "Unknown state for capstone: $capstone" + ;; +esac ########################################## # check if we have fdatasync @@ -6165,7 +6200,7 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi -if test "$capstone" = "yes" ; then +if test "$capstone" != "no" ; then echo "CONFIG_CAPSTONE=y" >> $config_host_mak fi @@ -6650,6 +6685,9 @@ done # for target in $targets if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi +if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then + echo "config-host.h: subdir-capstone" >> $config_host_mak +fi if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak